Skip to content

Commit

Permalink
Merge branch 'master' into rxsocks
Browse files Browse the repository at this point in the history
  • Loading branch information
RockyLOMO committed Dec 7, 2024
2 parents be2d828 + c293773 commit c409609
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions rxlib/src/main/java/org/rx/net/Sockets.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

0 comments on commit c409609

Please sign in to comment.