]> git.ipfire.org Git - thirdparty/git.git/commit
fsmonitor: use pthread_cond_timedwait for cookie wait
authorPaul Tarjan <github@paulisageek.com>
Wed, 15 Apr 2026 13:27:29 +0000 (13:27 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 15 Apr 2026 15:44:32 +0000 (08:44 -0700)
commit56cef9cb1a083c47b12b88548bf2126af8bfb263
tree900434d32976c9671eb5e43c871cb76afbec34b5
parent8372c88f583b8910f1e57c00c89c0afcca7018dc
fsmonitor: use pthread_cond_timedwait for cookie wait

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.

Signed-off-by: Paul Tarjan <github@paulisageek.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fsmonitor--daemon.c