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

Error Creating PollEvented for RawFd #2413 #2419

Merged
merged 1 commit into from
May 11, 2020

Conversation

dbcfd
Copy link
Contributor

@dbcfd dbcfd commented Apr 20, 2020

Add additional methods to allow PollEvented to be created with an appropriate
mio::Ready state so that it can be properly registered with the reactor.

Fixes #2413

@Darksonn Darksonn added A-tokio Area: The main tokio crate C-maintenance Category: PRs that clean code up or issues documenting cleanup. M-io Module: tokio/io S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 20, 2020
@Darksonn
Copy link
Contributor

You have some warnings that caused the CI to fail.

@Darksonn Darksonn added the S-waiting-on-author Status: awaiting some action (such as code changes) from the PR or issue author. label Apr 20, 2020
@dbcfd
Copy link
Contributor Author

dbcfd commented Apr 20, 2020

@Darksonn There's currently an unused method now in the PR. I don't think it would have any impact by removing it (seems to be internal to io), but wasn't sure if I should just remove it.

@Darksonn
Copy link
Contributor

Yeah, in this case it should be removed.

@dbcfd
Copy link
Contributor Author

dbcfd commented Apr 20, 2020

@Darksonn Removed.

@Darksonn Darksonn removed the S-waiting-on-author Status: awaiting some action (such as code changes) from the PR or issue author. label Apr 20, 2020
Copy link
Contributor

@kleimkuhler kleimkuhler left a comment

Choose a reason for hiding this comment

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

@dbcfd Overall the change in code looks good to me!

My main hesitation with adding this to the API is that it may be a point of confusion for new users. Someone new to Tokio may see both PollEvented::new and Poll::new_with_ready. If they intend to only read from the source (that is also writable), they may wonder why use new instead of new_with_ready.

It would require understanding the implementations of both that new_with_ready will not handle registering interest in HUP--errors should still be triggered without explicitly registering interest.

That being said, using the PollEvented API is not that usual so chances are the user is already in a situation where they have an understanding of Mio and the IO driver.

tokio/src/io/registration.rs Show resolved Hide resolved
@dbcfd
Copy link
Contributor Author

dbcfd commented Apr 20, 2020

If they intend to only read from the source (that is also writable), they may wonder why use new instead of new_with_ready.

I think this might be best addressed with documentation. Indicate that new_with_ready should be used if your source does not support both read and write.

@kleimkuhler
Copy link
Contributor

I think this might be best addressed with documentation. Indicate that new_with_ready should be used if your source does not support both read and write.

I would be good with that! If you can add that to the documentation then I should be good for approving this.

Copy link
Contributor

@kleimkuhler kleimkuhler left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks for adding the clarification about differentiating between the two methods.

I'd still like to get a quick review from @carllerche since this is an API addition.

Add additional methods to allow PollEvented to be created with an appropriate
`mio::Ready` state so that it can be properly registered with the reactor.
@carllerche
Copy link
Member

I think we are going to have to deprecate PollEvented long term (as we look into things like uring).

I'm ok w/ merging this now. That said, could we also try to solve the problem without PollEvented. Should we add a RawFd type that is hooked up w/ the reactor?

@dbcfd
Copy link
Contributor Author

dbcfd commented May 2, 2020

Would love just being able to hook a rawfd type up to reactor for polling.

@Darksonn
Copy link
Contributor

I am merging this per @carllerche's comments. Please see #2519 for solving the problem without PollEvented.

@Darksonn Darksonn merged commit 6aeeeff into tokio-rs:master May 11, 2020
jensim pushed a commit to jensim/tokio that referenced this pull request Jun 7, 2020
Add additional methods to allow PollEvented to be created with an appropriate
mio::Ready state, so that it can be properly registered with the reactor.

Fixes tokio-rs#2413
@dbcfd dbcfd deleted the poll-evented-error-2413 branch September 30, 2020 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-maintenance Category: PRs that clean code up or issues documenting cleanup. M-io Module: tokio/io S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error Creating PollEvented for RawFd
4 participants