Skip to content

Instantly share code, notes, and snippets.

@headius
Created April 20, 2015 14:22
Show Gist options
  • Save headius/773279de4bf1e300ad35 to your computer and use it in GitHub Desktop.
Save headius/773279de4bf1e300ad35 to your computer and use it in GitHub Desktop.
diff --git a/core/src/main/java/org/jruby/util/io/SelectExecutor.java b/core/src/main/java/org/jruby/util/io/SelectExecutor.java
index 9ea0a45..6138a14 100644
--- a/core/src/main/java/org/jruby/util/io/SelectExecutor.java
+++ b/core/src/main/java/org/jruby/util/io/SelectExecutor.java
@@ -117,7 +117,7 @@ public class SelectExecutor {
pendingReadFDs.add(fptr.fd());
}
}
- if (pendingReadFDs != null) { /* no blocking if there's buffered data */
+ if (pendingReadFDs != null || unselectableReadFDs != null) {/* ready to go if there's buffered data or we can't select */
timeout = (long) 0;
}
}
@@ -130,6 +130,9 @@ public class SelectExecutor {
fptr = write_io.getOpenFileChecked();
fdSetWrite(context, fptr.fd(), writeAry.size());
}
+ if (unselectableWriteFDs != null) {/* ready to go if we can't select */
+ timeout = (long) 0;
+ }
}
RubyArray exceptAry = null;
@@ -240,8 +243,8 @@ public class SelectExecutor {
}
private void fdSetRead(ThreadContext context, ChannelFD fd, int maxSize) throws IOException {
- if (fd.chFile != null || fd.isNativeFile) {
- // files are not selectable, so we treat them as ready
+ if (fd.chSelect == null) {
+ // channels that are not selectable are treated as always ready, like files
if (unselectableReadFDs == null) unselectableReadFDs = new ArrayList(1);
unselectableReadFDs.add(fd);
return;
@@ -253,8 +256,8 @@ public class SelectExecutor {
}
private void fdSetWrite(ThreadContext context, ChannelFD fd, int maxSize) throws IOException {
- if (fd.chFile != null || fd.isNativeFile) {
- // files are not selectable, so we treat them as ready
+ if (fd.chSelect == null) {
+ // channels that are not selectable are treated as always ready, like files
if (unselectableWriteFDs == null) unselectableWriteFDs = new ArrayList(1);
unselectableWriteFDs.add(fd);
return;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment