diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2009-04-20 17:13:19 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2009-04-20 17:13:19 +0000 |
commit | 5698171a3f3c7d8dd535466fd8f54e9deb8f170f (patch) | |
tree | 36ff31f9777790374e7960895e5650a459e8eac6 /winsup | |
parent | b978c43ea0ce397307c216e61b8fd405cd085b46 (diff) | |
download | newlib-5698171a3f3c7d8dd535466fd8f54e9deb8f170f.zip newlib-5698171a3f3c7d8dd535466fd8f54e9deb8f170f.tar.gz newlib-5698171a3f3c7d8dd535466fd8f54e9deb8f170f.tar.bz2 |
* flock.cc (lf_setlock): Handle border case which results in WFMO loop
exiting with ret == WAIT_TIMEOUT gracefully. Add a system_printf to
uncover other potential problems with WFMO loop.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/ChangeLog | 6 | ||||
-rw-r--r-- | winsup/cygwin/flock.cc | 8 |
2 files changed, 14 insertions, 0 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 59ac132..47b3efd 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2009-04-20 Corinna Vinschen <corinna@vinschen.de> + + * flock.cc (lf_setlock): Handle border case which results in WFMO loop + exiting with ret == WAIT_TIMEOUT gracefully. Add a system_printf to + uncover other potential problems with WFMO loop. + 2009-04-18 Christopher Faylor <me+cygwin@cgf.cx> * mkimport: Specify .text for stub explicitly. diff --git a/winsup/cygwin/flock.cc b/winsup/cygwin/flock.cc index e171660..8fd7139 100644 --- a/winsup/cygwin/flock.cc +++ b/winsup/cygwin/flock.cc @@ -971,6 +971,12 @@ lf_setlock (lockf_t *lock, inode_t *node, lockf_t **clean, HANDLE fhdl) ret = WaitForMultipleObjects (2, w4, FALSE, 100L); } while (ret == WAIT_TIMEOUT && get_obj_handle_count (obj) > 1); + /* There's a good chance that the above loop is left with + ret == WAIT_TIMEOUT if another process closes the file handle + associated with this lock. This is for all practical purposes + equivalent to a signalled lock object. */ + if (ret == WAIT_TIMEOUT) + ret = WAIT_OBJECT_0; } node->LOCK (); node->unwait (); @@ -991,6 +997,8 @@ lf_setlock (lockf_t *lock, inode_t *node, lockf_t **clean, HANDLE fhdl) _my_tls.call_signal_handler (); return EINTR; default: + system_printf ("Shouldn't happen! ret = %lu, error: %lu\n", + ret, GetLastError ()); return geterrno_from_win_error (); } } |