Subject: Re: [PATCH v7 04/10] fsmonitor: use pthread_cond_timedwait for cookie wait

From: Patrick Steinhardt <[email-masked]>
Date: Wed, 4 Mar 2026 08:42:53 +0100

On Thu, Feb 26, 2026 at 12:27:17AM +0000, Paul Tarjan via GitGitGadget wrote:
> From: Paul Tarjan <[email-masked]>
> 
> The cookie wait in with_lock__wait_for_cookie() uses an infinite
> pthread_cond_wait() loop.  The existing comment notes the desire
> to switch to pthread_cond_timedwait(), but the routine was not
> available in git thread-utils.
> 
> On certain container or overlay filesystems, inotify watches may
> succeed but events are never delivered.  In this case the daemon
> would hang indefinitely waiting for the cookie event, which in
> turn causes the client to hang.
> 
> Replace the infinite wait with a one-second timeout using
> pthread_cond_timedwait().  If the timeout fires, report an
> error and let the client proceed with a trivial (full-scan)
> response rather than blocking forever.

One thing that I'd be happy to learn about is why specifically you have
chosen one second as a timeout value. Are we sure this is always enough
on a loaded system?

Patrick