From 12bf0b6be68139c7f00a31411e665942fcfab7d5 Mon Sep 17 00:00:00 2001 From: Jade Lovelace Date: Sun, 23 Mar 2025 19:00:23 -0700 Subject: [PATCH] MonitorFdHup: shorten loop delay Apparently this is sometimes a problem for tests containing race conditions, since it caused the daemon processes to stick around for a second. Doesn't make writing such tests any less racey and foolish, but we can stop doing the silly thing regardless. CC: https://github.com/NixOS/nix/pull/12714#discussion_r2009265904 Change-Id: Iad6e55cf78c4a4517082194fa00a30d921224457 --- lix/libutil/monitor-fd.hh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lix/libutil/monitor-fd.hh b/lix/libutil/monitor-fd.hh index f160f0db7..095717e09 100644 --- a/lix/libutil/monitor-fd.hh +++ b/lix/libutil/monitor-fd.hh @@ -83,7 +83,13 @@ public: // 14.5) that in some limited cases on buggy kernel versions, // all the non-POLLHUP events for the socket get delivered. // Sleeping avoids pointlessly spinning a thread on those. - sleep(1); + // + // N.B. excessive delay on this can cause the daemon connection + // thread to live longer than the client and lead to + // synchronization problems if clients assume that the server + // thread has released its temporary gc roots, etc. + // See https://github.com/NixOS/nix/pull/12714#discussion_r2009265904 + usleep(1'000); } }); };