Skip to content

Wake the daemon poller with mio::Waker - #527

Merged
keepsimple1 merged 1 commit into
keepsimple1:mainfrom
orielhaim:waker-command-notify
Oct 20, 2026
Merged

keepsimple1 merged 1 commit into
keepsimple1:mainfrom
orielhaim:waker-command-notify

Conversation

@orielhaim

@orielhaim orielhaim commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Each command used to bind a loopback UDP socket and send a datagram whose only job was to interrupt mio::Poll. That depended on ephemeral ports and the local UDP stack, and a failed send could report an error after the command was already queued.

One Arc<mio::Waker> is created from the daemon Poll before the thread starts and shared by every cloned handle. The daemon thread keeps its own clone, so dropping a handle does not deregister the waker. mio allows a single Waker per Poll.

wake runs only after a successful try_send. A full channel is still Error::Again and a disconnected channel is still Error::DaemonShutdown, with no wake. If wake itself fails, the error is returned and the command stays queued: the error does not mean the command was rejected, and there is no rollback.

Wakeups are not command counts. mio may coalesce many wake calls into one event, and a wake issued before the first poll stays pending. After every poll the loop drains the flume receiver until it is empty, so a coalesced notification cannot drop a queued command.

Loopback UDP was only used to interrupt poll after a command was queued. One shared Waker removes that socket, and the flume queue remains the source of truth when wakeups coalesce.

@keepsimple1 keepsimple1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@keepsimple1
keepsimple1 merged commit 36f92a4 into keepsimple1:main Oct 20, 2026
8 checks passed
@orielhaim
orielhaim deleted the waker-command-notify branch October 20, 2026 05:23
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