1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2026-01-12 09:18:14 +01:00
Nix, the purely functional package manager
Find a file
Jörg Thalheim 212bf2b702 daemon: fix deadlock when SSH client disconnects during remote builds
When a remote SSH client disconnects during a long-running operation
like addToStore(), the nix-daemon can deadlock in a circular wait:

  - Process A (SSH daemon): blocked reading from downstream store socket,
    waiting for response from local daemon
  - Process B (local daemon): blocked reading from upstream socket,
    waiting for more NAR data from SSH daemon

The existing interrupt mechanism (ReceiveInterrupts + MonitorFdHup)
correctly detects the SSH disconnect and sets _isInterrupted, but the
daemon remains blocked in read() on the downstream store connection.
Even though SIGUSR1 causes read() to return EINTR, the circular
dependency prevents forward progress.

Fix this by adding shutdownConnections() to RemoteStore that calls
shutdown(fd, SHUT_RDWR) on all tracked connection file descriptors.
Register an interrupt callback in processConnection() that invokes
this method when the store is a RemoteStore. This causes any blocking
read() to return 0 (EOF), breaking the circular wait and allowing
both processes to exit cleanly.

The fix tracks connection FDs in a synchronized set, populated when
connections are created by the Pool factory. On interrupt, all FDs
are shut down regardless of whether they're idle or in-use.
2025-12-25 06:28:41 +00:00
.github Merge pull request #14805 from NixOS/dependabot/github_actions/cachix/install-nix-action-31.9.0 2025-12-16 19:58:01 +00:00
ci/gha ci/gha: Disable linkcheck on darwin 2025-11-05 15:38:23 +01:00
contrib
doc/manual Merge pull request #14843 from mdaniels5757/document-old-let-expression-syntax 2025-12-21 18:16:01 +00:00
maintainers Update release credits 2025-12-09 15:36:45 +01:00
misc zsh/completion: put compdef on first line 2025-10-29 18:09:42 +08:00
nix-meson-build-support build: Disable libstdc++ TBB backend to avoid unnecessary dependency 2025-11-07 20:58:46 +01:00
packaging packaging: disable LTO on cygwin 2025-12-20 22:52:44 -04:00
scripts Change channel URLs to channels.nixos.org subdomain 2025-11-09 15:28:12 +01:00
src daemon: fix deadlock when SSH client disconnects during remote builds 2025-12-25 06:28:41 +00:00
tests libcmd: improve --override-input error message clarity 2025-12-20 04:26:20 +01:00
.clang-format Update clang-format with fixing namespace coments, and separate definition blocks 2025-07-18 12:46:51 -04:00
.clang-tidy
.coderabbit.yaml .coderabbit.yaml: Kill chats 2025-11-04 22:55:18 +03:00
.dir-locals.el
.editorconfig No global eval settings in libnixexpr 2024-06-24 12:15:16 -04:00
.git-blame-ignore-revs git-blame-ignore-revs: Add nixfmt 1.0.0 reformat 2025-08-18 20:30:54 +03:00
.gitignore Overriding gtest with gmock 2025-05-31 07:41:27 -07:00
.shellcheckrc housekeeping: shellcheck for tests/functional/ca/build-cache.sh 2024-06-12 17:41:16 -04:00
.version Bump version 2025-12-10 17:35:28 +01:00
CITATION.cff
CONTRIBUTING.md chore: document we use sembr in the docs 2025-12-05 23:17:13 +01:00
COPYING COPYING: update to latest lgpl-2.1.txt (fixes #13758) 2025-09-18 00:45:01 +08:00
default.nix Format .nix files 2025-01-24 17:04:02 +01:00
docker.nix Change channel URLs to channels.nixos.org subdomain 2025-11-09 15:28:12 +01:00
flake.lock flake: Bump nixpkgs 2025-11-27 23:43:41 +03:00
flake.nix doc: make HTML manual build optional 2025-12-06 22:35:45 +01:00
HACKING.md Rename doc/manual{src -> source} 2024-10-14 11:21:24 -04:00
meson.build meson.build: Make schema checks optional 2025-11-07 15:15:56 -05:00
meson.format flake: Add meson formatter 2025-06-11 22:08:03 +00:00
meson.options meson.build: Make schema checks optional 2025-11-07 15:15:56 -05:00
README.md fix(docs): update Matrix channel links 2025-05-04 12:17:48 +02:00
shell.nix

Nix

Open Collective supporters CI

Nix is a powerful package manager for Linux and other Unix systems that makes package management reliable and reproducible. Please refer to the Nix manual for more details.

Installation and first steps

Visit nix.dev for installation instructions and beginner tutorials.

Full reference documentation can be found in the Nix manual.

Building and developing

Follow instructions in the Nix reference manual to set up a development environment and build Nix from source.

Contributing

Check the contributing guide if you want to get involved with developing Nix.

Additional resources

Nix was created by Eelco Dolstra and developed as the subject of his PhD thesis The Purely Functional Software Deployment Model, published 2006. Today, a world-wide developer community contributes to Nix and the ecosystem that has grown around it.

License

Nix is released under the LGPL v2.1.