windows: Finish pending writes when a socket is dropped#444
Closed
alexcrichton wants to merge 4 commits intotokio-rs:masterfrom
Closed
windows: Finish pending writes when a socket is dropped#444alexcrichton wants to merge 4 commits intotokio-rs:masterfrom
alexcrichton wants to merge 4 commits intotokio-rs:masterfrom
Conversation
That way as soon as the I/O object is dropped we'll stop receiving readiness notifications for it (as the handle has gone away).
No need to get synchronized access to this, it never changes.
To preserve the same semantics with Unix, when a `TcpStream` or `UdpSocket` is dropped, we wait to actually close the socket itself until any pending write has finished. To ensure that the socket closing is scheduled quickly, we do cancel any pending reads, however. Closes tokio-rs#423
4385f79 to
484236a
Compare
Now that we never close a socket early, there's no need to have any interior mutability. The socket provided is always valid and it can just live directly in the Arc.
484236a to
199156b
Compare
Member
|
\o/ I can test later if you'd like |
Member
|
Thanks. Merged into |
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.
On Unix the kernel will do this for us, but on Windows we need to do it ourselves. Previously we would forcibly close a socket whenever a socket was dropped on Windows. This would leave around its associated Arc (for completion events), but it would cancel all I/O in flight.
Now we instead allow writes to finish (we don't cancel them), and we just cancel any reads that are in flight. This should ensure that we actually get around to closing the socket in a timely fashion (not blocked on a read that'll never come) but we'll still ensure that all the data we said we wrote actually gets written.
Closes #423
cc @seanmonstar