Skip to content

Signal the queue's peer under its lock - #105

Merged
bavulapati merged 2 commits into
mainfrom
queue-locking
Aug 14, 2026
Merged

bavulapati merged 2 commits into
mainfrom
queue-locking

Conversation

@bavulapati

Copy link
Copy Markdown
Contributor

The signal callback is picked outside the lock and invoked after it is released, so a peer that retires its end in that window still gets called. The open state is published outside the lock too, for fields the peer reads under it.

Both move under the lock. The consequence worth knowing is that the callback now runs with the lock held, so it may only wake a run loop - never re-enter the queue - which is what all three platform implementations do.

Split out of #94, where this was tangled up with the transport change. Nothing consumes the queue on main yet, so this stands on its own.

The signal callback was chosen outside the lock and called after releasing it, so
a peer that retires its end in between is called anyway - it passes the open check
and then reaches a callback whose owner has already gone. The open state was
published outside the lock for the same fields the peer reads under it.

Both now happen under the lock, which means the callback may only wake the peer's
run loop and must never re-enter the queue.
Fails on the previous code for the reason that matters: the callback is chosen
outside the lock and invoked after it is released, so the lock is free while it
runs and a peer can retire its end underneath it.
@bavulapati
bavulapati merged commit da9630f into main Aug 14, 2026
11 checks passed
@bavulapati
bavulapati deleted the queue-locking branch August 14, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants