tdb: fix an early release of the global lock that can cause data corruption
commit0d755cd42cf2178cc961ef6388d2d97d049a65c6
authorVolker Lendecke <vl@samba.org>
Fri, 29 Jan 2010 17:21:09 +0000 (29 18:21 +0100)
committerFernando J V da Silva <fernandojvsilva@yahoo.com.br>
Thu, 4 Feb 2010 19:09:53 +0000 (4 17:09 -0200)
treed88cfd9b7918687c2211761ce5ca8447fad3b82e
parent9a7c60fcef67a02693021a1c0a1ebe3a452f2b12
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.
lib/tdb/common/transaction.c