Fix a bug with delegate/async SSL (#11537)
Motivation: This bug could occasionally cause SSL handshakes to time out, because the server-side handshake would fail to resume its event loop. Modification: Async delegate SSL tasks now lower their NEED_TASK status after they have executed, but before they run their completion callback. This is important because the completion callback could be querying the handshake status. This could cause the task delegator thread and the event look to race. If the event look queries the handshake status first, it might think that it still needs to delegate another task. If this happens, the delegator find a null task, and then fail to resume the event loop, causing the handshake to stall. Result: This data race no longer causes handshake timeouts.
This commit is contained in:
parent
202aee34c4
commit
4f0f889dbf
@ -1454,12 +1454,13 @@ public class ReferenceCountedOpenSslEngine extends SSLEngine implements Referenc
|
||||
runnable.run();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
task.runAsync(runnable);
|
||||
} finally {
|
||||
task.runAsync(() -> {
|
||||
// The task was run, reset needTask to false so getHandshakeStatus() returns the correct value.
|
||||
// This needs to be done before we run the completion runnable, since that might
|
||||
// query the handshake status.
|
||||
needTask = false;
|
||||
}
|
||||
runnable.run();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user