aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Drake <cygwin@jdrake.com>2025-08-18 15:59:54 -0700
committerJeremy Drake <cygwin@jdrake.com>2025-08-18 17:14:18 -0700
commit2934367c3d8096da72cac29e3404333fc2d3152f (patch)
tree626065f17380c73da1626261bc94e11d760205e6
parentfb0a539efa0278fd18915fc072bc30b4851a9b75 (diff)
downloadnewlib-2934367c3d8096da72cac29e3404333fc2d3152f.zip
newlib-2934367c3d8096da72cac29e3404333fc2d3152f.tar.gz
newlib-2934367c3d8096da72cac29e3404333fc2d3152f.tar.bz2
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")
-rw-r--r--winsup/cygwin/flock.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/winsup/cygwin/flock.cc b/winsup/cygwin/flock.cc
index e9f49a8..e03caba 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))