Skip to content

ipc: stop listeners in CapnpProtocol::disconnectIncoming() - #37009

Draft
mutatrum wants to merge 2 commits into
bitcoin:masterfrom
mutatrum:fix/ipc-stop-listeners-36585
Draft

mutatrum wants to merge 2 commits into
bitcoin:masterfrom
mutatrum:fix/ipc-stop-listeners-36585

Conversation

@mutatrum

@mutatrum mutatrum commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Related: #36585.

Depends on bitcoin-core/libmultiprocess#403 (fixes bitcoin-core/libmultiprocess#385).

Note: The first commit ([DO NOT MERGE]) temporarily mirrors the libmultiprocess PR in src/ipc/libmultiprocess/include/mp/proxy-io.h so CI can build and test this branch. It will be dropped once libmultiprocess merges and is subtree-synced.

Motivation

During Shutdown(), disconnectIncoming() closes existing IPC connections but leaves the listening socket open and present on disk. Auto-reconnecting IPC clients (such as mining clients like sv2-tp or ckpool) can reconnect in this window, acquiring a new EventLoopRef and causing ~CapnpProtocol() to hang indefinitely waiting for the reconnected client (#36585).

Change

src/ipc/capnp/protocol.cpp: Store the std::shared_ptr<mp::Listener> handles returned by mp::ListenConnections() in CapnpProtocol::m_listeners, and stop/clear them on m_loop->sync at the start of disconnectIncoming() (before removing existing m_incoming_connections) and in ~CapnpProtocol().

@DrahtBot DrahtBot added the IPC label Nov 29, 2026
@DrahtBot

DrahtBot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36572 (ipc: hold event loop references when using it in CapnpProtocol by nullfail)
  • #35932 (ipc: make ipc::disconnectIncoming wait for in-progress calls to complete by ryanofsky)
  • #32387 (ipc: add windows support by ryanofsky)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@mutatrum
mutatrum force-pushed the fix/ipc-stop-listeners-36585 branch from a1c05d0 to 73fbb3f Compare November 29, 2026 16:43
@DrahtBot

Copy link
Copy Markdown
Contributor

🚧 At least one of the CI tasks failed.
Task macOS native: https://github.com/bitcoin/bitcoin/actions/runs/46285602934/job/141417498195
LLM reason (✨ experimental): functional_test_fail: The functional test interface_ipc_cli.py failed; the other listed tests passed or were skipped.

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • Intermittent network issues can occur; re-run CI for now, and report the issue if they keep happening.

  • A functional or integration test failure may be intermittent or unrelated to this pull request.
    If no dedicated issue thread exists, create a new one to track it.

Leave a comment here, if you need help tracking down a confusing failure.

@mutatrum
mutatrum force-pushed the fix/ipc-stop-listeners-36585 branch from 73fbb3f to 74e9cc2 Compare November 29, 2026 18:30
@mutatrum mutatrum changed the title ipc: stop listeners and unlink unix sockets in disconnectIncoming() ipc: stop listeners in disconnectIncoming() Nov 29, 2026
@mutatrum mutatrum changed the title ipc: stop listeners in disconnectIncoming() ipc: stop listeners in CapnpProtocol::disconnectIncoming() Nov 29, 2026
@mutatrum
mutatrum force-pushed the fix/ipc-stop-listeners-36585 branch from 74e9cc2 to eb9f084 Compare November 29, 2026 21:08
@mutatrum
mutatrum force-pushed the fix/ipc-stop-listeners-36585 branch 2 times, most recently from f5d6bc1 to f384de3 Compare November 29, 2026 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Listeners can't be stopped, so bitcoin-node can hang after shutdown when an IPC client reconnects

2 participants