summaryrefslogtreecommitdiff
path: root/source3/lib/tdb/common/tdb.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-11-06 22:57:35 -0800
committerJeremy Allison <jra@samba.org>2007-11-06 22:57:35 -0800
commit3809490dd0ceb902c002bfeff09e6c04946e1a0c (patch)
tree115bfa178b8e55bd7229316e22a3849fac519366 /source3/lib/tdb/common/tdb.c
parentd8f3c9d0786ff637241d2a9409e1c7c253715ba5 (diff)
downloadsamba-3809490dd0ceb902c002bfeff09e6c04946e1a0c.tar.gz
samba-3809490dd0ceb902c002bfeff09e6c04946e1a0c.tar.bz2
samba-3809490dd0ceb902c002bfeff09e6c04946e1a0c.zip
Keep the tdb code in sync with Samba4.
Mainly this is the svn changes : ------------------------------------------------------------------------ r23238 | tridge | 2007-05-30 01:15:49 -0700 (Wed, 30 May 2007) | 6 lines merged transaction lock changes from ctdb this ensures that having the global lock also implies the transaction lock ------------------------------------------------------------------------ r22832 | tridge | 2007-05-13 18:00:06 -0700 (Sun, 13 May 2007) | 3 lines merged the latest tdb changes from ctdb to Samba4 Jeremy. (This used to be commit ab11c0055761e97ba32a8c3ec4fa6f8763a262cd)
Diffstat (limited to 'source3/lib/tdb/common/tdb.c')
-rw-r--r--source3/lib/tdb/common/tdb.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/source3/lib/tdb/common/tdb.c b/source3/lib/tdb/common/tdb.c
index 8f3c146843..0e9d1dbd74 100644
--- a/source3/lib/tdb/common/tdb.c
+++ b/source3/lib/tdb/common/tdb.c
@@ -30,10 +30,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;
@@ -41,16 +41,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);
}
@@ -653,3 +666,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;
+}