Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2012-02-15 18:43:07 +0400
committerCorinna Vinschen <corinna@vinschen.de>2012-02-15 18:43:07 +0400
commit5eb802f8ed164bce359bd604f3bb53cfa19fc69c (patch)
tree67c9689388966485674237d3708b33527e804507 /winsup/cygwin/flock.cc
parent1423a93374984f2d4fcd488681d463a90083d1af (diff)
* 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.
Diffstat (limited to 'winsup/cygwin/flock.cc')
-rw-r--r--winsup/cygwin/flock.cc28
1 files changed, 15 insertions, 13 deletions
diff --git a/winsup/cygwin/flock.cc b/winsup/cygwin/flock.cc
index 4f920643d..9b1de01a9 100644
--- a/winsup/cygwin/flock.cc
+++ b/winsup/cygwin/flock.cc
@@ -1006,16 +1006,22 @@ lf_setlock (lockf_t *lock, inode_t *node, lockf_t **clean, HANDLE fhdl)
HANDLE w4[4] = { obj, NULL, NULL, NULL };
DWORD wait_count = 1;
+ DWORD timeout;
HANDLE proc = NULL;
if (lock->lf_flags & F_POSIX)
{
proc = OpenProcess (SYNCHRONIZE, FALSE, block->lf_wid);
if (!proc)
- debug_printf ("Can't sync with process holding a POSIX lock "
- "(Win32 pid %lu): %E", block->lf_wid);
+ timeout = 0L;
else
- w4[wait_count++] = proc;
+ {
+ w4[wait_count++] = proc;
+ timeout = INFINITE;
+ }
}
+ else
+ timeout = 100L;
+
DWORD WAIT_SIGNAL_ARRIVED = WAIT_OBJECT_0 + wait_count;
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
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
- infinitely. Same problem for POSIX locks if the process has already
- exited at the time we're trying to open the process. */
+ infinitely. For POSIX locks, if the process has already exited,
+ just check if a signal or a thread cancel request arrived. */
SetThreadPriority (GetCurrentThread (), priority);
- DWORD ret = WaitForMultipleObjects (wait_count, w4, FALSE,
- proc ? INFINITE : 100L);
+ DWORD ret = WaitForMultipleObjects (wait_count, w4, FALSE, timeout);
SetThreadPriority (GetCurrentThread (), old_prio);
if (proc)
CloseHandle (proc);
@@ -1320,12 +1325,9 @@ lf_getblock (lockf_t *lock, inode_t *node)
/* Open the event object for synchronization. */
if (overlap->open_lock_obj ())
{
- /* If we found a POSIX lock, it will block us. */
- if (overlap->lf_flags & F_POSIX)
- return overlap;
- /* 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. */
+ /* 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))
return overlap;
overlap->close_lock_obj ();