Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSL: Hold the right monitor wheile running delegating task #13875

Merged
merged 1 commit into from Feb 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -41,7 +41,6 @@
import java.nio.ReadOnlyBufferException;
import java.security.Principal;
import java.security.cert.Certificate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -1522,16 +1521,20 @@ public void run(final Runnable runnable) {
}
}

private synchronized void runAndResetNeedTask(Runnable task) {
try {
if (isDestroyed()) {
// The engine was destroyed in the meantime, just return.
return;
private void runAndResetNeedTask(Runnable task) {
// We need to synchronize on the ReferenceCountedOpenSslEngine, we are sure the SSL object
// will not be freed by the user calling for example shutdown() concurrently.
synchronized (ReferenceCountedOpenSslEngine.this) {
try {
if (isDestroyed()) {
// The engine was destroyed in the meantime, just return.
return;
}
task.run();
} finally {
// The task was run, reset needTask to false so getHandshakeStatus() returns the correct value.
needTask = false;
}
task.run();
} finally {
// The task was run, reset needTask to false so getHandshakeStatus() returns the correct value.
needTask = false;
}
}

Expand Down