From c2937730ef9c2e89130dc6d6388d3aaee2707bd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=84=9E?= Date: Sat, 7 Dec 2024 22:43:51 +0800 Subject: [PATCH] up --- rxlib/src/main/java/org/rx/net/Sockets.java | 1 + rxlib/src/main/java/org/rx/net/socks/BackendRelayHandler.java | 2 +- rxlib/src/main/java/org/rx/net/socks/FrontendRelayHandler.java | 2 +- .../src/main/java/org/rx/net/socks/ProxyChannelIdleHandler.java | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rxlib/src/main/java/org/rx/net/Sockets.java b/rxlib/src/main/java/org/rx/net/Sockets.java index a93862a5d..9e579663e 100644 --- a/rxlib/src/main/java/org/rx/net/Sockets.java +++ b/rxlib/src/main/java/org/rx/net/Sockets.java @@ -370,6 +370,7 @@ public static void writeAndFlush(Channel channel, @NonNull Queue packs) { }); } + //ctx.channel()会为null public static void closeOnFlushed(Channel channel) { if (channel == null || !channel.isActive()) { return; diff --git a/rxlib/src/main/java/org/rx/net/socks/BackendRelayHandler.java b/rxlib/src/main/java/org/rx/net/socks/BackendRelayHandler.java index 4e13f2391..312fc35d7 100644 --- a/rxlib/src/main/java/org/rx/net/socks/BackendRelayHandler.java +++ b/rxlib/src/main/java/org/rx/net/socks/BackendRelayHandler.java @@ -38,8 +38,8 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) { @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { SocksContext sc = SocksContext.ctx(ctx.channel()); - Sockets.closeOnFlushed(sc.inbound); super.channelInactive(ctx); + Sockets.closeOnFlushed(sc.inbound); } @Override diff --git a/rxlib/src/main/java/org/rx/net/socks/FrontendRelayHandler.java b/rxlib/src/main/java/org/rx/net/socks/FrontendRelayHandler.java index 18623bdf9..61af64527 100644 --- a/rxlib/src/main/java/org/rx/net/socks/FrontendRelayHandler.java +++ b/rxlib/src/main/java/org/rx/net/socks/FrontendRelayHandler.java @@ -32,8 +32,8 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) { public void channelInactive(ChannelHandlerContext ctx) throws Exception { Channel inbound = ctx.channel(); SocksContext sc = SocksContext.ctx(inbound); - Sockets.closeOnFlushed(sc.outbound); super.channelInactive(ctx); + Sockets.closeOnFlushed(sc.outbound); } @Override diff --git a/rxlib/src/main/java/org/rx/net/socks/ProxyChannelIdleHandler.java b/rxlib/src/main/java/org/rx/net/socks/ProxyChannelIdleHandler.java index cd74d49ac..82f7e6698 100644 --- a/rxlib/src/main/java/org/rx/net/socks/ProxyChannelIdleHandler.java +++ b/rxlib/src/main/java/org/rx/net/socks/ProxyChannelIdleHandler.java @@ -18,11 +18,11 @@ public ProxyChannelIdleHandler(int readerIdleTimeSeconds, int writerIdleTimeSeco @Override protected void channelIdle(ChannelHandlerContext ctx, IdleStateEvent evt) { log.info("{} {} idle: {}", Sockets.protocolName(ctx.channel()), ctx.channel(), evt.state()); - Sockets.closeOnFlushed(ctx.channel()); SocksContext sc = SocksContext.ctx(ctx.channel()); if (sc.onClose != null) { sc.onClose.invoke(); } super.channelIdle(ctx, evt); + Sockets.closeOnFlushed(ctx.channel()); } }