From: Jeremy Allison Date: Tue, 20 Sep 2005 17:33:07 +0000 (+0000) Subject: r10355: Merge back the clear-if-first fix from Samba4. Couldn't wait tridge, sorry... X-Git-Tag: samba-4.0.0alpha6~801^2~9729 X-Git-Url: http://git.samba.org/samba.git/?a=commitdiff_plain;h=b3b2910f8fbcd12a717e6b9090a87a8db87c339f;p=nivanova%2Fsamba-autobuild%2F.git r10355: Merge back the clear-if-first fix from Samba4. Couldn't wait tridge, sorry :-). Jeremy. (This used to be commit b1722b7bd1eaabb725218a4fc5c8b012f0a1a0af) --- diff --git a/source3/tdb/tdb.c b/source3/tdb/tdb.c index 908657b355a..5d70c046d37 100644 --- a/source3/tdb/tdb.c +++ b/source3/tdb/tdb.c @@ -2071,6 +2071,11 @@ int tdb_reopen(TDB_CONTEXT *tdb) TDB_LOG((tdb, 0, "tdb_reopen: open failed (%s)\n", strerror(errno))); goto fail; } + if ((tdb->flags & TDB_CLEAR_IF_FIRST) && + (tdb_brlock(tdb, ACTIVE_LOCK, F_RDLCK, F_SETLKW, 0) == -1)) { + TDB_LOG((tdb, 0, "tdb_reopen: failed to obtain active lock\n")); + goto fail; + } if (fstat(tdb->fd, &st) != 0) { TDB_LOG((tdb, 0, "tdb_reopen: fstat failed (%s)\n", strerror(errno))); goto fail; @@ -2080,10 +2085,6 @@ int tdb_reopen(TDB_CONTEXT *tdb) goto fail; } tdb_mmap(tdb); - if ((tdb->flags & TDB_CLEAR_IF_FIRST) && (tdb_brlock(tdb, ACTIVE_LOCK, F_RDLCK, F_SETLKW, 0) == -1)) { - TDB_LOG((tdb, 0, "tdb_reopen: failed to obtain active lock\n")); - goto fail; - } return 0; @@ -2098,8 +2099,6 @@ int tdb_reopen_all(void) TDB_CONTEXT *tdb; for (tdb=tdbs; tdb; tdb = tdb->next) { - /* Ensure no clear-if-first. */ - tdb->flags &= ~TDB_CLEAR_IF_FIRST; if (tdb_reopen(tdb) != 0) return -1; }