{{ message }}
Repository navigation
ipc: hold event loop references when using it in CapnpProtocol - #36572
Open
xyzconstant wants to merge 1 commit into
Open
xyzconstant wants to merge 1 commit into
xyzconstant wants to merge 1 commit into
Conversation
EventLoop::loop() exits when its reference count reaches zero. In serve() mode, the parent connection is the only reference keeping the loop running. Other CapnpProtocol methods called from threads not handling parent IPC requests do not hold their own references and therefore depend on the parent connection remaining alive. Add loopRef(), which returns a new reference to the event loop or throws if the loop is not running or is shutting down, and use it in the methods that need the loop. Protect m_loop with a new m_loop_mutex to prevent serve() from destroying the loop while loopRef() is accessing it. Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
Contributor
This was referenced Oct 20, 2026
Husteem
reviewed
Oct 20, 2026
Comment on lines
+80
to
81
| assert(WITH_LOCK(m_loop_mutex, return !m_loop)); | ||
| }; |
There was a problem hiding this comment.
A tiny Nit: redundant trailing semicolon.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


EventLoop::loop()exits when its reference count reaches zero. Inserve()mode, the parent connection is the only reference keeping the loop running. OtherCapnpProtocolmethods called from threads not handling parent IPC requests do not hold their own references and therefore depend on the parent connection remaining alive.Add
loopRef()(code suggested by @ryanofsky in bitcoin-core/libmultiprocess#376 (comment)), which returns a new reference to the event loop or throws if the loop is not running or is shutting down, and use it in the methods that need the loop. Protectm_loopwith a newm_loop_mutexto preventserve()from destroying the loop whileloopRef()is accessing it.