Skip to content

Commit 0573941

Browse files
authored
Merge pull request #431 from tronprotocol/p2p_msg_queue
modify P2pHandler and message queue
2 parents c5b5452 + 5240b3f commit 0573941

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/main/java/org/tron/common/overlay/server/MessageQueue.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ private void sendToWire(MessageRoundtrip messageRoundtrip) {
173173

174174
if (messageRoundtrip.getRetryTimes() > 0){
175175
logger.warn("send msg timeout. close channel {}.", ctx.channel().remoteAddress());
176-
ctx.close();
176+
close();
177177
return;
178178
}
179179

@@ -193,6 +193,11 @@ private void sendToWire(MessageRoundtrip messageRoundtrip) {
193193

194194
public void close() {
195195
sendMsgThread.interrupt();
196-
timerTask.cancel(false);
196+
timerTask.cancel(true);
197+
if (ctx != null){
198+
ctx.close();
199+
ctx = null;
200+
}
197201
}
202+
198203
}

src/main/java/org/tron/common/overlay/server/P2pHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws E
100100

101101
public void closeChannel(ChannelHandlerContext ctx) {
102102
ctx.close();
103-
pingTask.cancel(false);
103+
pingTask.cancel(true);
104104
msgQueue.close();
105105
}
106106

0 commit comments

Comments
 (0)