tdb: fix an early release of the global lock that can cause data corruption
authorVolker Lendecke <vl@samba.org>
Fri, 29 Jan 2010 17:21:09 +0000 (18:21 +0100)
committerKarolin Seeger <kseeger@samba.org>
Wed, 10 Feb 2010 10:08:37 +0000 (11:08 +0100)
commitb538cbeb039f0780b462a987342787a8c2c7a625
treed29dd9e0c9414b965403e8159e9bec0673c275f4
parent728566d0e0a05c240cb5bc1f37878f438cf7524e
tdb: fix an early release of the global lock that can cause data corruption

There was a bug in tdb where the

                tdb_brlock(tdb, GLOBAL_LOCK, F_UNLCK, F_SETLKW, 0, 1);

(ending the transaction-"mutex") was done before the

                        /* remove the recovery marker */

This means that when a transaction is committed there is a window where another
opener of the file sees the transaction marker while the transaction committer
is still fully functional and working on it. This led to transaction being
rolled back by that second opener of the file while transaction_commit() gave
no error to the caller.

This patch moves the F_UNLCK to after the recovery marker was removed, closing
this window.
(cherry picked from commit 531059696e17d1ee538310d81af309c107d08e3e)

Fix bug #7085.
(cherry picked from commit ad17c1ab08e15ebf1d3d3aac1e874e9602a15e75)
lib/tdb/common/transaction.c