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

[ISSUE #8366] Eliminate deadlocks during the client shutdown process. #8367

Merged
merged 3 commits into from
Jul 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading