Skip to content
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

feat : add the ability to identify if tcp connection has failed #185

Merged
merged 14 commits into from
Jan 26, 2024

Conversation

irvingoujAtDevolution
Copy link
Contributor

@irvingoujAtDevolution irvingoujAtDevolution commented Jan 25, 2024

Added is_connection_failed method to identify if a tcp connection has failed, please see example tcp_client.rs.
Let me know if adding socket2 to dev-dependency is acceptable, I will remove it if not.

address #184

Copy link
Member

@notgull notgull left a comment

Choose a reason for hiding this comment

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

There should be a function on Poller indicating whether or not is_connect_failed is supported, like with edge triggered polling.

src/kqueue.rs Outdated

#[inline]
pub fn is_connect_failed(&self) -> bool {
unimplemented!("is connect failed is not supported on kqueue");
Copy link
Member

Choose a reason for hiding this comment

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

Just return false here, no need to panic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

Comment on lines 22 to 25
let Some(event) = event else {
println!("no event");
return Ok(());
};
Copy link
Member

Choose a reason for hiding this comment

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

Is this syntax compatible with Rust 1.63?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

///
/// This indicates a tcp connection has failed, it corresponds to the `EPOLLERR` along with `EPOLLHUP` event in linux
/// and `CONNECT_FAILED` event in windows IOCP.
///
Copy link
Member

Choose a reason for hiding this comment

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

This should have an example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

src/poll.rs Outdated
Comment on lines 432 to 434
// need reviewer's special attention, as I do not have access to a system that supports this
// this is a guess based on the documentation of `poll()`
self.flags.contains(PollFlags::ERR) || self.flags.contains(PollFlags::HUP)
Copy link
Member

Choose a reason for hiding this comment

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

This looks right to me

@notgull
Copy link
Member

notgull commented Jan 25, 2024

Actually, I think it might be a saner model to have it return Option<bool> and return None for BSD.

@irvingoujAtDevolution
Copy link
Contributor Author

irvingoujAtDevolution commented Jan 25, 2024

Actually, I think it might be a saner model to have it return Option<bool> and return None for BSD.

You mean for is_connect_failed?
if we don't support it, we return None, if we support it,we return the value?

do we still need supports_is_connect_failed in this case?

@notgull
Copy link
Member

notgull commented Jan 25, 2024

Yes, that's right. No we do not.

@irvingoujAtDevolution
Copy link
Contributor Author

Yes, that's right. No we do not.

updated!

Copy link
Member

@notgull notgull left a comment

Choose a reason for hiding this comment

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

Thanks!

@notgull notgull merged commit cf25dd8 into smol-rs:master Jan 26, 2024
24 checks passed
@notgull notgull mentioned this pull request Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants