Skip to content

Commit

Permalink
Merge pull request #4854 from wubin01/net
Browse files Browse the repository at this point in the history
feat(net): optimize network module close logic
  • Loading branch information
xxo1shine authored Dec 20, 2022
2 parents da32da7 + d4ff6c2 commit eb0065c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ private void processMessage(PeerConnection peer, byte[] data) {
type = msg.getType();
peer.getPeerStatistics().messageStatistics.addTcpInMessage(msg);
if (PeerConnection.needToLog(msg)) {
logger.info("Receive message from peer: {}, {}",
peer.getInetSocketAddress(), msg);
logger.info("Receive message from peer: {}, {}",
peer.getInetSocketAddress(), msg);
}
switch (type) {
case P2P_PING:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public String log() {
+ "remainNum:%d\n"
+ "syncChainRequested:%d\n"
+ "blockInProcess:%d\n",
channel.getInetAddress(),
channel.getInetSocketAddress(),
(now - channel.getStartTime()) / Constant.ONE_THOUSAND,
channel.getLatency(),
fastForwardBlock != null ? fastForwardBlock.getNum() : blockBothHave.getNum(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ public static void init() {

public static void close() {
try {
peers.forEach(p -> {
for (PeerConnection p : new ArrayList<>(peers)) {
if (!p.isDisconnect()) {
p.getChannel().close();
}
});
}
executor.shutdownNow();
} catch (Exception e) {
logger.error("Peer manager shutdown failed", e);
Expand Down

0 comments on commit eb0065c

Please sign in to comment.