From c156155239dafd68104a843916d8d737e6e61bed Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Thu, 26 May 2022 10:53:06 +0200 Subject: createUnixDomainSocket: listen(unix, 5 -> 100) This solves the error error: cannot connect to socket at '/nix/var/nix/daemon-socket/socket': Connection refused on build farm systems that are loaded but operating normally. I've seen this happen on an M1 mac running a loaded hercules-ci-agent. Hercules CI uses multiple worker processes, which may connect to the Nix daemon around the same time. It's not unthinkable that the Nix daemon listening process isn't scheduled until after 6 workers try to connect, especially on a system under load with many workers. Is the increase safe? The number is the number of connections that the kernel will buffer while the listening process hasn't `accept`-ed them yet. It did not - and will not - restrict the total number of daemon forks that a client can create. History The number 5 has remained unchanged since the introduction in nix-worker with 0130ef88ea in 2006. --- src/libutil/util.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libutil/util.cc') diff --git a/src/libutil/util.cc b/src/libutil/util.cc index d4d78329d..1c19938a8 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -1818,7 +1818,7 @@ AutoCloseFD createUnixDomainSocket(const Path & path, mode_t mode) if (chmod(path.c_str(), mode) == -1) throw SysError("changing permissions on '%1%'", path); - if (listen(fdSocket.get(), 5) == -1) + if (listen(fdSocket.get(), 100) == -1) throw SysError("cannot listen on socket '%1%'", path); return fdSocket; -- cgit v1.2.3