Replace KJ_DEFER with kj::defer #210

pull Sjors wants to merge 3 commits into bitcoin-core:master from Sjors:2025/08/kj-defer changing 3 files +126 −54
  1. Sjors commented at 9:16 am on September 10, 2025: member

    My understanding is that this doesn’t really matter much, e.g. tools like tidy and TSan won’t work better. They might produce slightly more readable output.

    It should however work for the all the versions of capnp that we support.

    Based on #201

  2. doc: describe ThreadContext struct and synchronization requirements 90d4a42a39
  3. bug: fix ProxyClient<Thread> deadlock if disconnected as IPC call is returning
    This bug is currently causing mptest "disconnecting and blocking" test to
    occasionally hang as reported by maflcko in
    https://github.com/bitcoin/bitcoin/issues/33244.
    
    The bug was actually first reported by Sjors in
    https://github.com/Sjors/bitcoin/pull/90#issuecomment-3024942087 and there are
    more details about it in
    https://github.com/bitcoin-core/libmultiprocess/issues/189.
    
    The bug is caused by the "disconnecting and blocking" test triggering a
    disconnect right before a server IPC call returns. This results in a race
    between the IPC server thread and the onDisconnect handler in the event loop thread both
    trying to destroy the server's request_threads ProxyClient<Thread> object when
    the IPC call is done.
    
    There was a lack of synchronization in this case, fixed here by adding
    loop->sync() various places. There were also lock order issues where
    Waiter::m_mutex could be incorrectly locked before EventLoop::m_mutex resulting
    in a deadlock.
    7a8a99c50f
  4. DrahtBot commented at 9:17 am on September 10, 2025: none

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

    Reviews

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

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #201 (bug: fix mptest hang, ProxyClient deadlock in disconnect handler 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 typos and grammar issues:

    • callback_thread and request_thread -> callback_threads and request_threads [the comment refers to the maps; the actual member names are plural “callback_threads” and “request_threads”, so using singular form is inconsistent and may confuse readers]
    • before thread client is, -> before the thread client is destroyed, [phrase is missing the word “destroyed” (or similar) and the article “the”, making the timing/meaning unclear]

    drahtbot_id_5_m

  5. Sjors commented at 9:17 am on September 10, 2025: member

    It should however work for the all the versions of capnp that we support.

    I mainly opened this PR to test this assumption, since one of the jobs test early releases.

    Feel free to close if it otherwise seems useless.

  6. Replace KJ_DEFER with kj::defer
    Review hint:
    git show --color-moved=dimmed-zebra --color-moved-ws=ignore-space-change
    a5056a45b4
  7. Sjors force-pushed on Sep 10, 2025
  8. DrahtBot added the label Needs rebase on Sep 17, 2025
  9. DrahtBot commented at 10:29 am on September 17, 2025: none
    🐙 This pull request conflicts with the target branch and needs rebase.
  10. Sjors commented at 12:05 pm on September 17, 2025: member
    CI passed, but closing this for now.
  11. Sjors closed this on Sep 17, 2025


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/libmultiprocess. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-12-04 19:30 UTC

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