1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +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)
{
struct ctdb_context *ctdb = ctdb_db->ctdb;
TDB_DATA rec;
TDB_DATA rec[2];
uint32_t hsize = sizeof(struct ctdb_ltdb_header);
int ret;
bool seqnum_suppressed = false;
@ -186,12 +186,11 @@ store:
*/
header->flags &= ~CTDB_REC_FLAG_AUTOMATIC;
rec.dsize = sizeof(*header) + data.dsize;
rec.dptr = talloc_size(ctdb, rec.dsize);
CTDB_NO_MEMORY(ctdb, rec.dptr);
rec[0].dsize = hsize;
rec[0].dptr = (uint8_t *)header;
memcpy(rec.dptr, header, sizeof(*header));
memcpy(rec.dptr + sizeof(*header), data.dptr, data.dsize);
rec[1].dsize = data.dsize;
rec[1].dptr = data.dptr;
/* Databases with seqnum updates enabled only get their seqnum
changes when/if we modify the data */
@ -215,7 +214,7 @@ store:
ctdb_hash(&key)));
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 {
ret = tdb_delete(ctdb_db->ltdb->tdb, key);
}
@ -242,8 +241,6 @@ store:
tdb_add_flags(ctdb_db->ltdb->tdb, TDB_SEQNUM);
}
talloc_free(rec.dptr);
if (schedule_for_deletion) {
int ret2;
ret2 = ctdb_local_schedule_for_deletion(ctdb_db, header, key);