summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2012-11-08 12:00:11 +0100
committerMichael Adam <obnox@samba.org>2012-11-29 17:52:02 +0100
commitaf608cdd8c6c2d5eaddcca90ccd8d075ddcb6c7e (patch)
tree6605ef6a3f2dbdb7f7332c8c4f10719c03f37972
parent71273448637e65b920535c077959e8dbb5444299 (diff)
downloadsamba-af608cdd8c6c2d5eaddcca90ccd8d075ddcb6c7e.tar.gz
samba-af608cdd8c6c2d5eaddcca90ccd8d075ddcb6c7e.tar.bz2
samba-af608cdd8c6c2d5eaddcca90ccd8d075ddcb6c7e.zip
s3: Use db_ctdb_ltdb_parse in db_ctdb_fetch_db_seqnum_from_db
Reviewed-by: Michael Adam <obnox@samba.org>
-rw-r--r--source3/lib/dbwrap/dbwrap_ctdb.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index 5e09e1d4c9..8a0f806e50 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -741,6 +741,19 @@ static NTSTATUS db_ctdb_delete_transaction(struct db_record *rec)
return status;
}
+static void db_ctdb_fetch_db_seqnum_parser(
+ TDB_DATA key, struct ctdb_ltdb_header *header,
+ TDB_DATA data, void *private_data)
+{
+ uint64_t *seqnum = (uint64_t *)private_data;
+
+ if (data.dsize != sizeof(uint64_t)) {
+ *seqnum = 0;
+ return;
+ }
+ memcpy(seqnum, data.dptr, sizeof(*seqnum));
+}
+
/**
* Fetch the db sequence number of a persistent db directly from the db.
*/
@@ -748,36 +761,24 @@ static NTSTATUS db_ctdb_fetch_db_seqnum_from_db(struct db_ctdb_ctx *db,
uint64_t *seqnum)
{
NTSTATUS status;
- const char *keyname = CTDB_DB_SEQNUM_KEY;
TDB_DATA key;
- TDB_DATA data;
- struct ctdb_ltdb_header header;
- TALLOC_CTX *mem_ctx = talloc_stackframe();
if (seqnum == NULL) {
return NT_STATUS_INVALID_PARAMETER;
}
- key = string_term_tdb_data(keyname);
+ key = string_term_tdb_data(CTDB_DB_SEQNUM_KEY);
- status = db_ctdb_ltdb_fetch(db, key, &header, mem_ctx, &data);
- if (!NT_STATUS_IS_OK(status) &&
- !NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND))
- {
- goto done;
- }
-
- status = NT_STATUS_OK;
+ status = db_ctdb_ltdb_parse(
+ db, key, db_ctdb_fetch_db_seqnum_parser, seqnum);
- if (data.dsize != sizeof(uint64_t)) {
+ if (NT_STATUS_IS_OK(status)) {
+ return NT_STATUS_OK;
+ }
+ if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
*seqnum = 0;
- goto done;
+ return NT_STATUS_OK;
}
-
- *seqnum = *(uint64_t *)data.dptr;
-
-done:
- TALLOC_FREE(mem_ctx);
return status;
}