Skip to content

Commit

Permalink
Ensure we always call quiche_conn_on_timeout(...) when a timeout is a…
Browse files Browse the repository at this point in the history
…bout to run (java-native-access#206)

Motivation:

If we cancel a timeout as its remaining time is elapsed we need to ensure we also call quiche_conn_on_timeout(...) as otherwise we may not produce the required  data.

Modifications:

Call run() directly when a timeout is elepsed

Result:

Timeouts are handled correctly
  • Loading branch information
normanmaurer authored Mar 1, 2021
1 parent 3313490 commit 62bad83
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,14 @@ void scheduleTimeout() {
nanos, TimeUnit.NANOSECONDS);
} else {
long remaining = timeoutFuture.getDelay(TimeUnit.NANOSECONDS);
if (remaining <= 0 || remaining > nanos) {
if (remaining <= 0) {
// This means the timer already elapsed. In this case just cancel the future and call run()
// directly. This will ensure we correctly call quiche_conn_on_timeout() etc.
cancel();
run();
} else if (remaining > nanos) {
// The new timeout is smaller then what was scheduled before. Let's cancel the old timeout
// and schedule a new one.
cancel();
timeoutFuture = eventLoop().schedule(this, nanos, TimeUnit.NANOSECONDS);
}
Expand Down

0 comments on commit 62bad83

Please sign in to comment.