New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't report RDHUP
as HUP
#939
Merged
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e610594
Add TCP shutdown test
carllerche c4abb6a
Tweak test
carllerche d8dd004
Fix RDHUP bug
carllerche af54d66
bump
carllerche f52c66f
Update test
carllerche 90bbff2
Listen for hup
carllerche 3534c78
Don't watch for EPOLLRDHUP in epoll
behrat c3e7aa3
Tweak the test
carllerche f84367a
Fix azure-pipelines.yml
carllerche 5315c7b
tweak condition and add comment
carllerche cabcd4b
remove double empty line
carllerche ecf947c
Link to HUP issue
carllerche File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
use std::net::Shutdown; | ||
use std::time::Duration; | ||
|
||
use mio::{Token, Ready, PollOpt, Poll, Events}; | ||
use mio::net::TcpStream; | ||
|
||
macro_rules! wait { | ||
($poll:ident, $ready:ident) => {{ | ||
use std::time::Instant; | ||
|
||
let now = Instant::now(); | ||
let mut events = Events::with_capacity(16); | ||
let mut found = false; | ||
|
||
while !found { | ||
if now.elapsed() > Duration::from_secs(5) { | ||
panic!("not ready"); | ||
} | ||
|
||
$poll.poll(&mut events, Some(Duration::from_secs(1))).unwrap(); | ||
|
||
for event in &events { | ||
#[cfg(unix)] | ||
{ | ||
use mio::unix::UnixReady; | ||
assert!(!UnixReady::from(event.readiness()).is_hup()); | ||
} | ||
|
||
if event.token() == Token(0) && event.readiness().$ready() { | ||
found = true; | ||
break; | ||
} | ||
} | ||
} | ||
}}; | ||
} | ||
|
||
#[test] | ||
fn test_write_shutdown() { | ||
let poll = Poll::new().unwrap(); | ||
|
||
let listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap(); | ||
let addr = listener.local_addr().unwrap(); | ||
|
||
let mut ready = Ready::readable() | Ready::writable(); | ||
|
||
#[cfg(unix)] | ||
{ | ||
ready |= mio::unix::UnixReady::hup(); | ||
} | ||
|
||
let client = TcpStream::connect(&addr).unwrap(); | ||
poll.register(&client, | ||
Token(0), | ||
ready, | ||
PollOpt::edge()).unwrap(); | ||
carllerche marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
let (socket, _) = listener.accept().unwrap(); | ||
|
||
wait!(poll, is_writable); | ||
|
||
let mut events = Events::with_capacity(16); | ||
|
||
// Polling should not have any events | ||
poll.poll(&mut events, Some(Duration::from_millis(100))).unwrap(); | ||
assert!(events.iter().next().is_none()); | ||
|
||
println!("SHUTTING DOWN"); | ||
// Now, shutdown the write half of the socket. | ||
socket.shutdown(Shutdown::Write).unwrap(); | ||
|
||
wait!(poll, is_readable); | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this means passing HUP readiness is a no-op on epoll platforms right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No,
HUP
is an implicit interest w/ epoll (you always get it). The error here was requestingRDHUP
which means something different.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right
EPOLLHUP
is implicit but it won't be possible to getEPOLLRDHUP
anymore right?