[PATCH v2] Cygwin: lockf: Make lockf() return ENOLCK when too many locks
Corinna Vinschen
corinna-cygwin@cygwin.com
Thu Oct 24 10:27:38 GMT 2024
On Oct 24 17:59, Takashi Yano wrote:
> Previously, lockf() printed a warning message when the number of locks
> per file exceeds the limit (MAX_LOCKF_CNT). This patch makes lockf()
> return ENOLCK in that case rather than printing the warning message.
>
> Addresses: https://cygwin.com/pipermail/cygwin/2024-October/256528.html
> Fixes: 31390e4ca643 ("(inode_t::get_all_locks_list): Use pre-allocated buffer in i_all_lf instead of allocating every lock. Return pointer to start of linked list of locks.")
> 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>
> ---
> winsup/cygwin/flock.cc | 68 +++++++++++++++++++++++++++++++++++++-----
> 1 file changed, 60 insertions(+), 8 deletions(-)
>
> diff --git a/winsup/cygwin/flock.cc b/winsup/cygwin/flock.cc
> index 5550b3a5b..b05005dab 100644
> --- a/winsup/cygwin/flock.cc
> +++ b/winsup/cygwin/flock.cc
> @@ -610,17 +614,13 @@ inode_t::get_all_locks_list ()
> dbi->ObjectName.Buffer[LOCK_OBJ_NAME_LEN] = L'\0';
> if (!newlock.from_obj_name (this, &i_all_lf, dbi->ObjectName.Buffer))
> continue;
> - if (lock - i_all_lf >= MAX_LOCKF_CNT)
> - {
> - system_printf ("Warning, can't handle more than %d locks per file.",
> - MAX_LOCKF_CNT);
> - break;
> - }
> + assert (lock - i_all_lf < MAX_LOCKF_CNT);
Shouldn't that be a <=? The original test above was off-by-one, right?
But I still don't get it. The successful assert() will end the process
as well, just like api_fatal. Shouldn't this situation just return
ENOLCK as well, as the commit message suggests?
Thanks,
Corinna
More information about the Cygwin-patches
mailing list