* flock.cc (lf_setlock): Add timeout variable and set before calling
WFMO. Drop debug output if process is not available. Set timeout to 0 instead. Document timeout 0 in WFMO comment. (lf_getblock): Drop invalid F_POSIX lock type shortcut. Only return overlap if event is not signalled. Fix comment.
This commit is contained in:
parent
1423a93374
commit
5eb802f8ed
|
@ -1,3 +1,11 @@
|
||||||
|
2012-02-15 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* flock.cc (lf_setlock): Add timeout variable and set before calling
|
||||||
|
WFMO. Drop debug output if process is not available. Set timeout to
|
||||||
|
0 instead. Document timeout 0 in WFMO comment.
|
||||||
|
(lf_getblock): Drop invalid F_POSIX lock type shortcut. Only return
|
||||||
|
overlap if event is not signalled. Fix comment.
|
||||||
|
|
||||||
2012-02-14 Christopher Faylor <me.cygwin2012@cgf.cx>
|
2012-02-14 Christopher Faylor <me.cygwin2012@cgf.cx>
|
||||||
|
|
||||||
* pinfo.cc (_pinfo::set_ctty): Revert 2012-02-07 change to skip
|
* pinfo.cc (_pinfo::set_ctty): Revert 2012-02-07 change to skip
|
||||||
|
|
|
@ -1006,16 +1006,22 @@ lf_setlock (lockf_t *lock, inode_t *node, lockf_t **clean, HANDLE fhdl)
|
||||||
HANDLE w4[4] = { obj, NULL, NULL, NULL };
|
HANDLE w4[4] = { obj, NULL, NULL, NULL };
|
||||||
DWORD wait_count = 1;
|
DWORD wait_count = 1;
|
||||||
|
|
||||||
|
DWORD timeout;
|
||||||
HANDLE proc = NULL;
|
HANDLE proc = NULL;
|
||||||
if (lock->lf_flags & F_POSIX)
|
if (lock->lf_flags & F_POSIX)
|
||||||
{
|
{
|
||||||
proc = OpenProcess (SYNCHRONIZE, FALSE, block->lf_wid);
|
proc = OpenProcess (SYNCHRONIZE, FALSE, block->lf_wid);
|
||||||
if (!proc)
|
if (!proc)
|
||||||
debug_printf ("Can't sync with process holding a POSIX lock "
|
timeout = 0L;
|
||||||
"(Win32 pid %lu): %E", block->lf_wid);
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
w4[wait_count++] = proc;
|
w4[wait_count++] = proc;
|
||||||
|
timeout = INFINITE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
timeout = 100L;
|
||||||
|
|
||||||
DWORD WAIT_SIGNAL_ARRIVED = WAIT_OBJECT_0 + wait_count;
|
DWORD WAIT_SIGNAL_ARRIVED = WAIT_OBJECT_0 + wait_count;
|
||||||
w4[wait_count++] = signal_arrived;
|
w4[wait_count++] = signal_arrived;
|
||||||
|
|
||||||
|
@ -1033,11 +1039,10 @@ lf_setlock (lockf_t *lock, inode_t *node, lockf_t **clean, HANDLE fhdl)
|
||||||
creator process. We have to make sure the event object is in a
|
creator process. We have to make sure the event object is in a
|
||||||
signalled state, or that it has gone away. The latter we can only
|
signalled state, or that it has gone away. The latter we can only
|
||||||
recognize by retrying to fetch the block list, so we must not wait
|
recognize by retrying to fetch the block list, so we must not wait
|
||||||
infinitely. Same problem for POSIX locks if the process has already
|
infinitely. For POSIX locks, if the process has already exited,
|
||||||
exited at the time we're trying to open the process. */
|
just check if a signal or a thread cancel request arrived. */
|
||||||
SetThreadPriority (GetCurrentThread (), priority);
|
SetThreadPriority (GetCurrentThread (), priority);
|
||||||
DWORD ret = WaitForMultipleObjects (wait_count, w4, FALSE,
|
DWORD ret = WaitForMultipleObjects (wait_count, w4, FALSE, timeout);
|
||||||
proc ? INFINITE : 100L);
|
|
||||||
SetThreadPriority (GetCurrentThread (), old_prio);
|
SetThreadPriority (GetCurrentThread (), old_prio);
|
||||||
if (proc)
|
if (proc)
|
||||||
CloseHandle (proc);
|
CloseHandle (proc);
|
||||||
|
@ -1320,12 +1325,9 @@ lf_getblock (lockf_t *lock, inode_t *node)
|
||||||
/* Open the event object for synchronization. */
|
/* Open the event object for synchronization. */
|
||||||
if (overlap->open_lock_obj ())
|
if (overlap->open_lock_obj ())
|
||||||
{
|
{
|
||||||
/* If we found a POSIX lock, it will block us. */
|
/* Check if the event object is signalled. If so, the overlap
|
||||||
if (overlap->lf_flags & F_POSIX)
|
doesn't actually exist anymore. There are just a few open
|
||||||
return overlap;
|
handles left. */
|
||||||
/* In case of BSD flock locks, check if the event object is
|
|
||||||
signalled. If so, the overlap doesn't actually exist anymore.
|
|
||||||
There are just a few open handles left. */
|
|
||||||
if (!IsEventSignalled (overlap->lf_obj))
|
if (!IsEventSignalled (overlap->lf_obj))
|
||||||
return overlap;
|
return overlap;
|
||||||
overlap->close_lock_obj ();
|
overlap->close_lock_obj ();
|
||||||
|
|
Loading…
Reference in New Issue