Skip to content

Commit

Permalink
[ISSUE #8366] Eliminate deadlocks during the client shutdown process. (
Browse files Browse the repository at this point in the history
…#8367)

* [ISSUE #8366] When determining if `ChannelWrapper` is the wrapper for a channel, no longer acquire a read lock.

* [ISSUE #8366] Compare channels for equality using `isWrapperOf`.
  • Loading branch information
YanYunyang authored Jul 18, 2024
1 parent cf4234b commit 9115d66
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ public void closeChannel(final String addr, final Channel channel) {
if (null == prevCW) {
LOGGER.info("closeChannel: the channel[{}] has been removed from the channel table before", addrRemote);
removeItemFromTable = false;
} else if (prevCW.getChannel() != channel) {
} else if (prevCW.isWrapperOf(channel)) {
LOGGER.info("closeChannel: the channel[{}] has been closed before, and has been created again, nothing to do.",
addrRemote);
removeItemFromTable = false;
Expand Down Expand Up @@ -463,12 +463,10 @@ public void closeChannel(final Channel channel) {
for (Map.Entry<String, ChannelWrapper> entry : channelTables.entrySet()) {
String key = entry.getKey();
ChannelWrapper prev = entry.getValue();
if (prev.getChannel() != null) {
if (prev.getChannel() == channel) {
prevCW = prev;
addrRemote = key;
break;
}
if (prev.isWrapperOf(channel)) {
prevCW = prev;
addrRemote = key;
break;
}
}

Expand Down Expand Up @@ -1022,6 +1020,13 @@ public boolean isWritable() {
return getChannel().isWritable();
}

public boolean isWrapperOf(Channel channel) {
if (this.channelFuture.channel() != null && this.channelFuture.channel() == channel) {
return true;
}
return false;
}

private Channel getChannel() {
return getChannelFuture().channel();
}
Expand Down

0 comments on commit 9115d66

Please sign in to comment.