[newlib-cygwin] Cygwin: fix finding overlaps from F_SETLKW.
Jeremy Drake
jeremyd2019@sourceware.org
Tue Aug 19 17:14:43 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=2934367c3d8096da72cac29e3404333fc2d3152f
commit 2934367c3d8096da72cac29e3404333fc2d3152f
Author: Jeremy Drake <cygwin@jdrake.com>
Date: Mon Aug 18 15:59:54 2025 -0700
Cygwin: fix finding overlaps from F_SETLKW.
The commit adding OFD locks changed from comparing just the F_POSIX and
F_LOCK flags to comparing the entire flags value in order to make sure
the locks are of the same type. However, the F_WAIT flag may or may not
be set, and result in that comparison not matching. Mask the F_WAIT
flag when attempting to compare the types of the locks.
This fixes the "many_locks" stc.
Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
Fixes: a66ed519884d ("Cygwin: fcntl: implement Open File Description (OFD) locks")
Diff:
---
winsup/cygwin/flock.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/winsup/cygwin/flock.cc b/winsup/cygwin/flock.cc
index e9f49a890..e03caba27 100644
--- a/winsup/cygwin/flock.cc
+++ b/winsup/cygwin/flock.cc
@@ -1722,7 +1722,7 @@ lf_findoverlap (lockf_t *lf, lockf_t *lock, int type, lockf_t ***prev,
/* We're "self" only if the semantics and the id matches. OFD and POSIX
locks potentially block each other. This is true even for OFD and
POSIX locks created by the same process. */
- bool self = (lf->lf_flags == lock->lf_flags)
+ bool self = ((lf->lf_flags & ~F_WAIT) == (lock->lf_flags & ~F_WAIT))
&& (lf->lf_id == lock->lf_id);
if (bsd_flock || ((type & SELF) && !self) || ((type & OTHERS) && self))
More information about the Cygwin-cvs
mailing list