ipc: support per-address max-connections options on -ipcbind #35037

pull enirox001 wants to merge 3 commits into bitcoin:master from enirox001:04-26-ipcbind-max-connections-draft changing 12 files +282 −26
  1. enirox001 commented at 1:44 pm on April 9, 2026: contributor

    This is a draft follow-up to #34978 to make the per-address IPC connection-limit approach concrete.

    The branch extends -ipcbind to accept :max-connections=<n> options, for example -ipcbind=unix::max-connections=8 or -ipcbind=unix:/custom/path:max-connections=8, instead of introducing a separate global -ipcmaxconnections option.

    It also adds the local listener limit support needed in libmultiprocess and threads the parsed per-address limit through to ListenConnections() so each listener can stop accepting new IPC connections after reaching its local cap and resume accepting after a disconnect.

    The draft includes:

    • parser coverage for -ipcbind max-connections and invalid inputs
    • functional init coverage for FD reservation logging and init errors
    • an IPC behavior test verifying that with max_connections=1, a second client only becomes usable after the first disconnects

    This is intended to help evaluate the per-address approach downstream against the global-limit direction in #34978.

  2. DrahtBot commented at 1:44 pm on April 9, 2026: contributor

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Concept ACK ryanofsky

    If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #34978 (init: Reserve file descriptors for IPC connections by enirox001)
    • #32427 ((RFC) kernel: Replace leveldb-based BlockTreeDB with flat-file based store by sedited)
    • #32387 (ipc: add windows support by ryanofsky)
    • #17783 (common: Disallow calling IsArgSet() on ALLOW_LIST options by ryanofsky)
    • #17581 (refactor: Remove settings merge reverse precedence code by ryanofsky)
    • #17580 (refactor: Add ALLOW_LIST flags and enforce usage in CheckArgFlags by ryanofsky)
    • #17493 (util: Forbid ambiguous multiple assignments in config file 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.

    LLM Linter (✨ experimental)

    Possible places where named args for integral literals may be used (e.g. func(x, /*named_arg=*/0) in C++, and func(x, named_arg=0) in Python):

    • check_bind(“unix::max-connections=8”, “unix:”, 8, “”) in src/ipc/test/ipc_tests.cpp
    • check_bind(“unix:path.sock:max-connections=8”, “unix:path.sock”, 8, “”) in src/ipc/test/ipc_tests.cpp
    • check_bind(“unix:path.sock:max-connections=8,unknown=1”, “”, 0, “Unknown socket option ‘unknown’”) in src/ipc/test/ipc_tests.cpp
    • check_bind(“unix:max-connections=8”, “”, 0, “Missing unix socket path before socket options; use unix:: for the default path”) in src/ipc/test/ipc_tests.cpp
    • check_bind(“unix::max-connections=-1”, “”, 0, “Invalid max-connections value ‘-1’”) in src/ipc/test/ipc_tests.cpp
    • check_bind(“unix::max-connections=”, “”, 0, “Missing value for max-connections option”) in src/ipc/test/ipc_tests.cpp

    2026-04-09 14:56:02

  3. enirox001 renamed this:
    04 26 ipcbind max connections draft
    ipc: support per-address max-connections options on -ipcbind
    on Apr 9, 2026
  4. enirox001 force-pushed on Apr 9, 2026
  5. DrahtBot added the label CI failed on Apr 9, 2026
  6. enirox001 force-pushed on Apr 9, 2026
  7. ryanofsky commented at 2:40 pm on April 9, 2026: contributor

    Concept ACK. Looks like suggestions from #35036 (comment) apply here too (sorry, saw that PR first in my inbox).

    IMO this is a better alternative to adding a new -ipcmaxconnections option like #34978, and I’d prefer this approach but both approaches seem reasonable. Main reason I prefer this approach is IPC is a pretty generic feature, so it seems useful to be able to set different limits for different purposes (like GUIs vs mining clients).

  8. ipc: add per-address max-connections parsing for -ipcbind
    Replace the global -ipcmaxconnections option with per-address
    max-connections parsing on -ipcbind values. Update init argument
    documentation, parse and validate :max-connections=<n> suffixes, and
    reserve file descriptors by summing accepted-connection limits across
    all configured IPC listeners.
    
    Reject ambiguous syntax like unix:max-connections=8 so option-looking
    input is not silently treated as a literal socket path.
    
    Extend IPC parser coverage and functional startup coverage to check the
    new -ipcbind forms, FD reservation logging, and init errors for invalid
    max-connections values.
    aadc51fb5f
  9. ipc: pass per-address connection limits to ListenConnections
    Thread optional per-address max-connections values through the Bitcoin
    IPC stack and the vendored libmultiprocess listener implementation.
    
    Update interfaces::Ipc and ipc::Protocol listen methods to accept an
    optional connection limit, pass parsed -ipcbind limits from init, and
    use the vendored ListenConnections(..., max_connections) support so each
    listener stops accepting new IPC connections after reaching its local
    cap and resumes accepting after a disconnect.
    76f53ca4c7
  10. ipc: test per-address connection limiting over unix sockets
    Add a Bitcoin-side IPC test covering the local listener limit behavior
    through ipc::Process and ipc::Protocol over a real unix socket.
    
    The new test starts a listener with max_connections=1, verifies the
    first client is served immediately, checks that a second client remains
    blocked while the first connection stays open, and then confirms the
    second client becomes usable after the first disconnects. This keeps the
    downstream draft from relying only on vendored libmultiprocess tests and
    startup log assertions.
    57a0a29303
  11. enirox001 force-pushed on Apr 9, 2026
  12. enirox001 commented at 3:50 pm on April 9, 2026: contributor

    Thanks for the review @ryanofsky

    I pushed updates based on your review here as well

    • the bind-address type is now shared
    • parsing moved behind the interfaces::Ipc boundary
    • the parser handles trailing socket options
    • listenAddress() now takes the bind-address struct directly

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-12 09:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me