John Baldwin e838f09cd0 Reorder the managament of advisory locks on open files so that the advisory
lock is obtained before the write count is increased during open() and the
lock is released after the write count is decreased during close().

The first change closes a race where an open() that will block with O_SHLOCK
or O_EXLOCK can increase the write count while it waits.  If the process
holding the current lock on the file then tries to call exec() on the file
it has locked, it can fail with ETXTBUSY even though the advisory lock is
preventing other threads from succesfully completeing a writable open().

The second change closes a race where a read-only open() with O_SHLOCK or
O_EXLOCK may return successfully while the write count is non-zero due to
another descriptor that had the advisory lock and was blocking the open()
still being in the process of closing.  If the process that completed the
open() then attempts to call exec() on the file it locked, it can fail with
ETXTBUSY even though the other process that held a write lock has closed
the file and released the lock.

Reviewed by:	kib
MFC after:	1 month
2012-07-31 18:25:00 +00:00
..
2012-05-31 19:32:37 +00:00
2012-05-31 19:34:53 +00:00
2012-05-24 11:24:44 +00:00
2011-12-05 10:34:52 +00:00
2011-04-13 11:28:46 +00:00
2012-03-28 20:58:30 +00:00
2012-03-28 20:58:30 +00:00
2012-03-28 20:58:30 +00:00
2012-03-28 20:58:30 +00:00
2012-03-28 20:58:30 +00:00
2011-07-10 00:53:04 +00:00
2012-06-25 05:41:16 +00:00
2012-01-02 12:12:10 +00:00
2012-02-01 14:34:52 +00:00
2012-01-26 16:35:09 +00:00
2012-06-11 18:47:26 +00:00
2012-06-10 20:24:01 +00:00
2012-05-25 21:52:57 +00:00
2012-05-25 21:52:57 +00:00
2012-01-02 12:12:10 +00:00
2012-07-03 19:08:02 +00:00