{
struct ctdb_context *ctdb = ctdb_db->ctdb;
TDB_DATA rec;
+ uint32_t hsize = sizeof(struct ctdb_ltdb_header);
int ret;
bool seqnum_suppressed = false;
}
if (ctdb->flags & CTDB_FLAG_TORTURE) {
+ TDB_DATA old;
struct ctdb_ltdb_header *h2;
- rec = tdb_fetch(ctdb_db->ltdb->tdb, key);
- h2 = (struct ctdb_ltdb_header *)rec.dptr;
- if (rec.dptr && rec.dsize >= sizeof(h2) && h2->rsn > header->rsn) {
- DEBUG(DEBUG_CRIT,("RSN regression! %llu %llu\n",
- (unsigned long long)h2->rsn, (unsigned long long)header->rsn));
+
+ old = tdb_fetch(ctdb_db->ltdb->tdb, key);
+ h2 = (struct ctdb_ltdb_header *)old.dptr;
+ if (old.dptr != NULL && old.dsize >= hsize &&
+ h2->rsn > header->rsn) {
+ DEBUG(DEBUG_ERR,
+ ("RSN regression! %"PRIu64" %"PRIu64"\n",
+ h2->rsn, header->rsn));
+ }
+ if (old.dptr != NULL) {
+ free(old.dptr);
}
- if (rec.dptr) free(rec.dptr);
}
rec.dsize = sizeof(*header) + data.dsize;
TDB_DATA old;
old = tdb_fetch(ctdb_db->ltdb->tdb, key);
- if ( (old.dsize == rec.dsize)
- && !memcmp(old.dptr+sizeof(struct ctdb_ltdb_header),
- rec.dptr+sizeof(struct ctdb_ltdb_header),
- rec.dsize-sizeof(struct ctdb_ltdb_header)) ) {
+ if ((old.dsize == hsize + data.dsize) &&
+ memcmp(old.dptr+hsize, data.dptr, data.dsize) == 0) {
tdb_remove_flags(ctdb_db->ltdb->tdb, TDB_SEQNUM);
seqnum_suppressed = true;
}
- if (old.dptr) free(old.dptr);
+ if (old.dptr != NULL) {
+ free(old.dptr);
+ }
}
ret = tdb_store(ctdb_db->ltdb->tdb, key, rec, TDB_REPLACE);
if (ret != 0) {