Skip to content

Commit

Permalink
Treat all unselectables as ready and return immediately for them.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Apr 20, 2015
1 parent 1630b58 commit d6c1248
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions core/src/main/java/org/jruby/util/io/SelectExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ IRubyObject selectInternal(ThreadContext context) throws IOException {
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;
}
}
Expand All @@ -130,6 +130,9 @@ IRubyObject selectInternal(ThreadContext context) throws IOException {
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;
Expand Down Expand Up @@ -240,8 +243,8 @@ private int maxWriteReadySize() {
}

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;
Expand All @@ -253,8 +256,8 @@ private void fdSetRead(ThreadContext context, ChannelFD fd, int maxSize) throws
}

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;
Expand Down

0 comments on commit d6c1248

Please sign in to comment.