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: a998dd7055 ("* flock.cc: Implement all advisory file locking here.")
Reported-by: Christian Franke <Christian.Franke@t-online.de>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
This commit is contained in:
Takashi Yano 2024-10-20 00:59:51 +09:00
parent 5e6eb2f200
commit f9cc21dc00
2 changed files with 8 additions and 3 deletions

View File

@ -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;
}

View File

@ -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