-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This closes OpenTSDB#4.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1130,6 +1130,7 @@ private T doJoin(final boolean interruptible, final long timeout) | |
try { | ||
while (true) { | ||
try { | ||
boolean timedout = false; | ||
synchronized (signal_cb) { | ||
addBoth((Callback<T, T>) ((Object) signal_cb)); | ||
if (timeout == 0) { // No timeout, we can use a simple loop. | ||
|
@@ -1174,12 +1175,15 @@ private T doJoin(final boolean interruptible, final long timeout) | |
// But entering `wait' is pretty much guaranteed to make the | ||
// loop take more than 100ns no matter what. | ||
if (timeleft < 100) { | ||
throw new TimeoutException(this, timeout); | ||
timedout = true; | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
if (signal_cb.result instanceof Exception) { | ||
if (timedout) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
tsuna
Author
Owner
|
||
throw new TimeoutException(this, timeout); | ||
} else if (signal_cb.result instanceof Exception) { | ||
throw (Exception) signal_cb.result; | ||
} | ||
return (T) signal_cb.result; | ||
|
Very minor suggestion, should we do a signal_cb.result != signal_cb check and then throw the timeoutException ?. That may lead to dirty code but this is the situation which lead to deadlock in our case the callback chain just finished in time to join, better to have result than exception