Skip to content

Commit

Permalink
GH-2504: Clear Deffered Channel Close Executor
Browse files Browse the repository at this point in the history
Addendum to #2504 - when the connection is reset, the `channelsExecutor`
is shut down. It needs to be reset so that a new one is created, if necessary.

Also fix synchronization.

**cherry-pick to 2.4.x**
  • Loading branch information
garyrussell authored Aug 4, 2023
1 parent b860606 commit 5dd01b7
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -846,18 +846,24 @@ public final void destroy() {
resetConnection();
if (getContextStopped()) {
this.stopped = true;
if (this.channelsExecutor != null) {
try {
if (!this.inFlightAsyncCloses.await(CHANNEL_EXEC_SHUTDOWN_TIMEOUT, TimeUnit.SECONDS)) {
this.logger.warn("Async closes are still in-flight: " + this.inFlightAsyncCloses.getCount());
synchronized (this.connectionMonitor) {
if (this.channelsExecutor != null) {
try {
if (!this.inFlightAsyncCloses.await(CHANNEL_EXEC_SHUTDOWN_TIMEOUT, TimeUnit.SECONDS)) {
this.logger
.warn("Async closes are still in-flight: " + this.inFlightAsyncCloses.getCount());
}
this.channelsExecutor.shutdown();
if (!this.channelsExecutor.awaitTermination(CHANNEL_EXEC_SHUTDOWN_TIMEOUT, TimeUnit.SECONDS)) {
this.logger.warn("Channel executor failed to shut down");
}
}
this.channelsExecutor.shutdown();
if (!this.channelsExecutor.awaitTermination(CHANNEL_EXEC_SHUTDOWN_TIMEOUT, TimeUnit.SECONDS)) {
this.logger.warn("Channel executor failed to shut down");
catch (@SuppressWarnings(UNUSED) InterruptedException e) {
Thread.currentThread().interrupt();
}
finally {
this.channelsExecutor = null;
}
}
catch (@SuppressWarnings(UNUSED) InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}
Expand Down

0 comments on commit 5dd01b7

Please sign in to comment.