You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/04/20 03:48:53 UTC

[GitHub] [rocketmq] RongtongJin commented on a diff in pull request #3975: [ISSUE #3929] wake up client’s waiting when server crashed

RongtongJin commented on code in PR #3975:
URL: https://github.com/apache/rocketmq/pull/3975#discussion_r853700590


##########
remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java:
##########
@@ -38,12 +38,7 @@
 import java.io.IOException;
 import java.net.SocketAddress;
 import java.security.cert.CertificateException;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.Timer;
-import java.util.TimerTask;
+import java.util.*;

Review Comment:
   Do not import xxx.*



##########
remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java:
##########
@@ -707,5 +711,25 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws E
                 NettyRemotingClient.this.putNettyEvent(new NettyEvent(NettyEventType.EXCEPTION, remoteAddress, ctx.channel()));
             }
         }
+
+        @Override
+        public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+            Channel channel = ctx.channel();
+            if (null == channel) {
+                return;
+            }
+            if (responseTable != null) {
+                Iterator<Map.Entry<Integer, ResponseFuture>> it = responseTable.entrySet().iterator();
+                while (it.hasNext()) {
+                    Map.Entry<Integer, ResponseFuture> entry = it.next();
+                    if (channel == entry.getValue().getProcessChannel()) {
+                        final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(ctx.channel());
+                        log.warn("NETTY CLIENT PIPELINE: channelInactive, so wakeup response, the channel[{}]", remoteAddress);
+                        entry.getValue().wakeupResponse();
+                    }
+                }
+            }
+            super.channelInactive(ctx);
+        }

Review Comment:
   In order to solve the issueeof timeout, is it worth scanning all items of responseTable?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org