summaryrefslogtreecommitdiff
path: root/source4/lib/tdb/common/tdb.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2007-05-14 01:00:06 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:52:22 -0500
commita2b250258502907399dbbe9f738d4212c1b0618e (patch)
tree5eeda7f0cbdb6a91a9a3260ed95afe70fb88851b /source4/lib/tdb/common/tdb.c
parentbf27e58c2f1ce897a222a63bc1771716e90d5672 (diff)
downloadsamba-a2b250258502907399dbbe9f738d4212c1b0618e.tar.gz
samba-a2b250258502907399dbbe9f738d4212c1b0618e.tar.bz2
samba-a2b250258502907399dbbe9f738d4212c1b0618e.zip
r22832: merged the latest tdb changes from ctdb to Samba4
(This used to be commit a88ab4fa3a07c31bc45c612043f9e096f384eda4)
Diffstat (limited to 'source4/lib/tdb/common/tdb.c')
-rw-r--r--source4/lib/tdb/common/tdb.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/source4/lib/tdb/common/tdb.c b/source4/lib/tdb/common/tdb.c
index 25103d826e..70d050e7e6 100644
--- a/source4/lib/tdb/common/tdb.c
+++ b/source4/lib/tdb/common/tdb.c
@@ -31,10 +31,10 @@
TDB_DATA tdb_null;
/*
- increment the tdb sequence number if the tdb has been opened using
+ non-blocking increment of the tdb sequence number if the tdb has been opened using
the TDB_SEQNUM flag
*/
-static void tdb_increment_seqnum(struct tdb_context *tdb)
+void tdb_increment_seqnum_nonblock(struct tdb_context *tdb)
{
tdb_off_t seqnum=0;
@@ -42,16 +42,29 @@ static void tdb_increment_seqnum(struct tdb_context *tdb)
return;
}
- if (tdb_brlock(tdb, TDB_SEQNUM_OFS, F_WRLCK, F_SETLKW, 1, 1) != 0) {
- return;
- }
-
/* we ignore errors from this, as we have no sane way of
dealing with them.
*/
tdb_ofs_read(tdb, TDB_SEQNUM_OFS, &seqnum);
seqnum++;
tdb_ofs_write(tdb, TDB_SEQNUM_OFS, &seqnum);
+}
+
+/*
+ increment the tdb sequence number if the tdb has been opened using
+ the TDB_SEQNUM flag
+*/
+static void tdb_increment_seqnum(struct tdb_context *tdb)
+{
+ if (!(tdb->flags & TDB_SEQNUM)) {
+ return;
+ }
+
+ if (tdb_brlock(tdb, TDB_SEQNUM_OFS, F_WRLCK, F_SETLKW, 1, 1) != 0) {
+ return;
+ }
+
+ tdb_increment_seqnum_nonblock(tdb);
tdb_brlock(tdb, TDB_SEQNUM_OFS, F_UNLCK, F_SETLKW, 1, 1);
}
@@ -649,3 +662,11 @@ int tdb_get_flags(struct tdb_context *tdb)
return tdb->flags;
}
+
+/*
+ enable sequence number handling on an open tdb
+*/
+void tdb_enable_seqnum(struct tdb_context *tdb)
+{
+ tdb->flags |= TDB_SEQNUM;
+}