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 18 files +515 −30
  1. enirox001 commented at 1:44 PM on April 9, 2026: contributor

    <!-- *** Please remove the following help text before submitting: *** Pull requests without a rationale and clear improvement may be closed immediately. GUI-related pull requests should be opened against https://github.com/bitcoin-core/gui first. See CONTRIBUTING.md -->

    <!-- Please provide clear motivation for your patch and explain how it improves Bitcoin Core user experience or Bitcoin Core developer experience significantly: * Any test improvements or new tests that improve coverage are always welcome. * All other changes should have accompanying unit tests (see `src/test/`) or functional tests (see `test/`). Contributors should note which tests cover modified code. If no tests exist for a region of modified code, new tests should accompany the change. * Bug fixes are most welcome when they come with steps to reproduce or an explanation of the potential issue as well as reasoning for the way the bug was fixed. * Features are welcome, but might be rejected due to design or scope issues. If a feature is based on a lot of dependencies, contributors should first consider building the system outside of Bitcoin Core, if possible. * Refactoring changes are only accepted if they are required for a feature or bug fix or otherwise improve developer experience significantly. For example, most "code style" refactoring changes require a thorough explanation why they are useful, what downsides they have and why they *significantly* improve developer experience or avoid serious programming bugs. Note that code style is often a subjective matter. Unless they are explicitly mentioned to be preferred in the [developer notes](/doc/developer-notes.md), stylistic code changes are usually rejected. -->

    <!-- Bitcoin Core has a thorough review process and even the most trivial change needs to pass a lot of eyes and requires non-zero or even substantial time effort to review. There is a huge lack of active reviewers on the project, so patches often sit for a long time. -->

    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

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Concept ACK ryanofsky, kevkevinpal

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #35084 (ipc: Support for windows support by ryanofsky)
    • #34978 (init: Reserve file descriptors for IPC connections by enirox001)
    • #34806 (refactor: logging: Various API improvements by ajtowns)
    • #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.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  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. enirox001 force-pushed on Apr 9, 2026
  9. 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
  10. in test/functional/interface_ipc_init.py:29 in aadc51fb5f outdated
      24 | +        super().setup_nodes()
      25 | +        self.nodes[0].args = [arg for arg in self.nodes[0].args if not arg.startswith("-ipcbind=")]
      26 | +        self.ipc_tmpdir = tempfile.TemporaryDirectory(prefix="btc-ipc-init-")
      27 | +        self.ipcbind_path = Path(self.ipc_tmpdir.name) / "ipcinit.sock"
      28 | +
      29 | +    def test_ipcbind_max_connections(self):
    


    ViniciusCestarii commented at 5:21 PM on April 9, 2026:

    Same suggestion I made on #34978. It would be good to have a functional test case where max-connections is not specified, to verify the default value is actually applied correctly


    enirox001 commented at 11:49 AM on April 20, 2026:

    Thanks for the suggestion, applied in the latest push

  11. kevkevinpal commented at 3:43 PM on April 13, 2026: contributor

    Concept ACK

    I agree with Ryanofsky. I think this approach seems more reasonable than #34978, even though both can work and both make sense this seems cleaner. I think it makes sense to go with this approach instead of adding the -ipcmaxconnections option.

  12. fanquake commented at 1:02 PM on April 14, 2026: member

    cc @Sjors

  13. enirox001 force-pushed on Apr 20, 2026
  14. enirox001 force-pushed on Apr 20, 2026
  15. enirox001 force-pushed on Apr 20, 2026
  16. enirox001 force-pushed on Apr 20, 2026
  17. enirox001 force-pushed on Apr 20, 2026
  18. enirox001 force-pushed on Apr 20, 2026
  19. enirox001 force-pushed on Apr 20, 2026
  20. enirox001 force-pushed on Apr 21, 2026
  21. ipc: update libmultiprocess subtree to include local connection limit support
    git-subtree-dir: src/ipc/libmultiprocess
    git-subtree-split: 8511c68f8b6827f4e9b306e0245929965a363930
    540d55dc7c
  22. enirox001 force-pushed on Apr 21, 2026
  23. enirox001 force-pushed on Apr 21, 2026
  24. ipc: add per-address max-connections parsing and support for -ipcbind
    Thread optional per-address max-connections values through the listener
    implementation.
    
    Update interfaces::Ipc and ipc::Protocol listen methods to accept an
    optional connection limit, pass parsed -ipcbind limits from init, and
    use ListenConnections(..., max_connections) support so each
    listener stops accepting new IPC connections after reaching its local
    cap and resumes accepting after a disconnect.
    01f82cbc2a
  25. ipc: test per-address connection limiting over unix sockets
    Add an IPC test covering the local listener limit behavior
    through ipc::Process and ipc::Protocol over a 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.
    2d214431d0
  26. enirox001 force-pushed on Apr 21, 2026
  27. enirox001 commented at 9:07 AM on April 21, 2026: contributor

    Had a peer review with @Eunovo a few days ago, and I pushed a few follow-up changes to make the branch a bit easier to review:

    • Updated ParseBindAddress() to return util::Result, and adjusted the callers/tests accordingly.
    • Extended parser coverage to include 0, large valid values, and negative/overflow cases.
    • Cleaned up the commit structure so the branch is split into a subtree update, per-address integration, and tests.
    • Fixed the IPC limit test by correcting the async lifetime issue that could trigger disconnect errors.

    The remaining subtree lint failure is expected for this draft, since the branch carries the libmultiprocess subtree update ahead of the upstream merge.


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-05-02 12:12 UTC

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