Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c295c1e5685a
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c3f9783e822a
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Jul 19, 2016

  1. Copy the full SHA
    c5a2be2 View commit details
  2. [Truffle] stop looping indefinitely with 0 timeout in select

    it was wrongly considered as interrupted
    pitr-ch committed Jul 19, 2016
    Copy the full SHA
    c3f9783 View commit details
Showing with 12 additions and 4 deletions.
  1. +12 −4 truffle/src/main/java/org/jruby/truffle/core/rubinius/IOPrimitiveNodes.java
Original file line number Diff line number Diff line change
@@ -624,8 +624,13 @@ public Object selectWritables(DynamicObject readables, DynamicObject writables,
return selectOneSet(writables, timeoutMicros, 2);
}

@Specialization(guards = { "isNilOrEmpty(readables)", "isNilOrEmpty(writables)", "isRubyArray(errorables)" })
public Object selectErrorables(DynamicObject readables, DynamicObject writables, DynamicObject errorables, int timeoutMicros) {
return selectOneSet(errorables, timeoutMicros, 3);
}

@TruffleBoundary(throwsControlFlowException = true)
private Object selectOneSet(DynamicObject setToSelect, int timeoutMicros, int setNb) {
private Object selectOneSet(DynamicObject setToSelect, final int timeoutMicros, int setNb) {
assert setNb >= 1 && setNb <= 3;
final Object[] readableObjects = ArrayOperations.toObjectArray(setToSelect);
final int[] fds = getFileDescriptors(setToSelect);
@@ -642,11 +647,14 @@ public Integer block(Timeval timeoutToUse) throws InterruptedException {
}
final int result = callSelect(nfds, fdSet, timeoutToUse);

if (result == 0) {
if (result == 0 && timeoutMicros != 0) {
// interrupted, try again
return null;
} else {
// result == 0: nothing was ready
// result > 0: some were ready
return result;
}

return result;
}

private int callSelect(int nfds, FDSet fdSet, Timeval timeoutToUse) {