This is an automated email from the ASF dual-hosted git repository.

lizhanhui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/develop by this push:
     new e7850f63e [ISSUE #5095] [Remoting-D] Not handle more request when 
channel write ability changed to un-writeable (#5176)
e7850f63e is described below

commit e7850f63e58d9879997785572e26b55866272bfb
Author: lizhimins <[email protected]>
AuthorDate: Fri Sep 23 16:54:38 2022 +0800

    [ISSUE #5095] [Remoting-D] Not handle more request when channel write 
ability changed to un-writeable (#5176)
    
    Co-authored-by: 斜阳 <[email protected]>
---
 .../rocketmq/remoting/netty/NettyRemotingServer.java    | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git 
a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java
 
b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java
index a80434545..5af8c7621 100644
--- 
a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java
+++ 
b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java
@@ -515,6 +515,23 @@ public class NettyRemotingServer extends 
NettyRemotingAbstract implements Remoti
             // The related remoting server has been shutdown, so close the 
connected channel
             RemotingUtil.closeChannel(ctx.channel());
         }
+
+        @Override
+        public void channelWritabilityChanged(ChannelHandlerContext ctx) 
throws Exception {
+            Channel channel = ctx.channel();
+            if (channel.isWritable()) {
+                if (!channel.config().isAutoRead()) {
+                    channel.config().setAutoRead(true);
+                    log.info("Channel[{}] turns writable, bytes to buffer 
before changing channel to un-writable: {}",
+                        RemotingHelper.parseChannelRemoteAddr(channel), 
channel.bytesBeforeUnwritable());
+                }
+            } else {
+                channel.config().setAutoRead(false);
+                log.warn("Channel[{}] auto-read is disabled, bytes to drain 
before it turns writable: {}",
+                    RemotingHelper.parseChannelRemoteAddr(channel), 
channel.bytesBeforeWritable());
+            }
+            super.channelWritabilityChanged(ctx);
+        }
     }
 
     @ChannelHandler.Sharable

Reply via email to