1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

ctdb-daemon: Simplify code using tdb_storev

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
Amitay Isaacs 2016-09-02 17:53:32 +10:00 committed by Jeremy Allison
parent 47298ed5ba
commit 3c03754921

View File

@ -57,7 +57,7 @@ static int ctdb_ltdb_store_server(struct ctdb_db_context *ctdb_db,
TDB_DATA data) TDB_DATA data)
{ {
struct ctdb_context *ctdb = ctdb_db->ctdb; struct ctdb_context *ctdb = ctdb_db->ctdb;
TDB_DATA rec; TDB_DATA rec[2];
uint32_t hsize = sizeof(struct ctdb_ltdb_header); uint32_t hsize = sizeof(struct ctdb_ltdb_header);
int ret; int ret;
bool seqnum_suppressed = false; bool seqnum_suppressed = false;
@ -186,12 +186,11 @@ store:
*/ */
header->flags &= ~CTDB_REC_FLAG_AUTOMATIC; header->flags &= ~CTDB_REC_FLAG_AUTOMATIC;
rec.dsize = sizeof(*header) + data.dsize; rec[0].dsize = hsize;
rec.dptr = talloc_size(ctdb, rec.dsize); rec[0].dptr = (uint8_t *)header;
CTDB_NO_MEMORY(ctdb, rec.dptr);
memcpy(rec.dptr, header, sizeof(*header)); rec[1].dsize = data.dsize;
memcpy(rec.dptr + sizeof(*header), data.dptr, data.dsize); rec[1].dptr = data.dptr;
/* Databases with seqnum updates enabled only get their seqnum /* Databases with seqnum updates enabled only get their seqnum
changes when/if we modify the data */ changes when/if we modify the data */
@ -215,7 +214,7 @@ store:
ctdb_hash(&key))); ctdb_hash(&key)));
if (keep) { if (keep) {
ret = tdb_store(ctdb_db->ltdb->tdb, key, rec, TDB_REPLACE); ret = tdb_storev(ctdb_db->ltdb->tdb, key, rec, 2, TDB_REPLACE);
} else { } else {
ret = tdb_delete(ctdb_db->ltdb->tdb, key); ret = tdb_delete(ctdb_db->ltdb->tdb, key);
} }
@ -242,8 +241,6 @@ store:
tdb_add_flags(ctdb_db->ltdb->tdb, TDB_SEQNUM); tdb_add_flags(ctdb_db->ltdb->tdb, TDB_SEQNUM);
} }
talloc_free(rec.dptr);
if (schedule_for_deletion) { if (schedule_for_deletion) {
int ret2; int ret2;
ret2 = ctdb_local_schedule_for_deletion(ctdb_db, header, key); ret2 = ctdb_local_schedule_for_deletion(ctdb_db, header, key);