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

Definite bug in core/src/main/java/org/jruby/util/io/SelectExecutor.java #4867

Closed
nick-someone opened this issue Nov 26, 2017 · 3 comments
Closed
Milestone

Comments

@nick-someone
Copy link
Contributor

Coming from #4860

if (errorKeyList.contains(fptr.fd())) {

Here and just below, errorKeyList, a List<ErrorKey>, is queried for containment of fptr.fd() (a ChannelFD). Perhaps, instead, pendingReadFDs or one of the other List<ChannelFD> fields in the file should be checked instead?

@headius
Copy link
Member

headius commented Nov 27, 2017

The logic here is a bit misleading. The code here is largely in place just for matching up with the MRI implementation of select.

In JRuby, no IO are ever put into the errorKeyList which means none of them will ever trigger the logic you pointed out. This is because there's no logic in the JDK's Selector to select streams for errors. We just go through the motions, as mentioned earlier in the file, but since there's no way to register for errors...we don't.

The logic could probably be boiled down to just the side effect calls (such as verifying opennes of IO passed in the error argument), but it would only be to clean up the code (which is a valid reason).

@headius
Copy link
Member

headius commented Nov 27, 2017

To be honest, this whole thing should be rewritten for efficiency, but the complexities of handling both selectable and non-selectable, native and JDK-provided streams has kept me from tackling it.

@headius
Copy link
Member

headius commented Nov 28, 2017

Closing this for now. I tried a simple optimization that fast-paths single read selects and it seemed to have little effect on overall performance. The dummy error logic will remain in place for now, since it's rarely used and reflects how MRI's select is implemented.

@headius headius closed this as completed Nov 28, 2017
@headius headius added this to the Won't Fix milestone Nov 28, 2017
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

No branches or pull requests

2 participants