Skip to content

Relax shutdown() receiver to &self - #31

Closed
dilluti0n wants to merge 1 commit into
Rubensei:masterfrom
dilluti0n:relax-shutdown-receiver-to-self
Closed

dilluti0n wants to merge 1 commit into
Rubensei:masterfrom
dilluti0n:relax-shutdown-receiver-to-self

Conversation

@dilluti0n

Copy link
Copy Markdown
Contributor

Unblocking WinDivertRecv() from another thread is in fact the whole purpose of WinDivertShutdown(), but &mut self made that impossible on a shared (Arc) handle. It only reads self.handle and doesn't invalidate it, so &self is sound.

Downstream usage: https://github.com/dilluti0n/dpibreak/blob/e14866ca04ad2909c456411c301cb8a9434c2473/src/platform/windows.rs#L42-L48

fn shutdown_all() {
    for h in RECV_HANDLES.lock().expect("mutex poisoned").iter() {
        if let Err(e) = h.shutdown(WinDivertShutdownMode::Both) {
            crate::warn!("windivert: shutdown: {e}");
        }
    }
}

Unblocking WinDivertRecv() from another thread is in fact the whole
purpose of WinDivertShutdown(), but &mut self made that impossible on
a shared (Arc) handle. It only reads self.handle and doesn't
invalidate it, so &self is sound.
@Rubensei

Copy link
Copy Markdown
Owner

This is a breaking change, and in 0.7 the signature has already been changed to fn shutdown(&self) -> ShutdownHandle, being the return type both Send and Sync

@Rubensei Rubensei closed this Jul 16, 2026
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