https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b76735a5719375cf9d33d63612092ff8516e99a0
commit b76735a5719375cf9d33d63612092ff8516e99a0 Author: Takashi Yano <[email protected]> Date: Sun Oct 20 00:59:51 2024 +0900 Cygwin: lockf: Fix adding a new lock over multiple locks Previously, adding a new lock by lockf() over multiple existing locks failed. This is due to a bug that lf_setlock() tries to create a lock that has already been created. This patch fixes the issue. Addresses: https://cygwin.com/pipermail/cygwin/2024-October/256528.html Fixes: a998dd705576 ("* flock.cc: Implement all advisory file locking here.") Reported-by: Christian Franke <[email protected]> Reviewed-by: Corinna Vinschen <[email protected]> Signed-off-by: Takashi Yano <[email protected]> Diff: --- winsup/cygwin/flock.cc | 7 ++++--- winsup/cygwin/release/3.5.5 | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/flock.cc b/winsup/cygwin/flock.cc index 0f1efa01d..5550b3a5b 100644 --- a/winsup/cygwin/flock.cc +++ b/winsup/cygwin/flock.cc @@ -1454,13 +1454,14 @@ lf_setlock (lockf_t *lock, inode_t *node, lockf_t **clean, HANDLE fhdl) /* * Add the new lock before overlap. */ - if (needtolink) { + if (needtolink) + { *prev = lock; lock->lf_next = overlap; - } + lock->create_lock_obj (); + } overlap->lf_start = lock->lf_end + 1; lf_wakelock (overlap, fhdl); - lock->create_lock_obj (); overlap->create_lock_obj (); break; } diff --git a/winsup/cygwin/release/3.5.5 b/winsup/cygwin/release/3.5.5 index bcc2c661b..ca96edf04 100644 --- a/winsup/cygwin/release/3.5.5 +++ b/winsup/cygwin/release/3.5.5 @@ -12,3 +12,7 @@ Fixes: Addresses: https://sourceware.org/pipermail/cygwin/2024-September/256468.html - Fix timer_delete() return value which always indicated failure. + +- Fix lockf() error which occurs when adding a new lock over multiple + locks. + Addresses: https://cygwin.com/pipermail/cygwin/2024-October/256528.html
