From 6fb8ee4844a010559dc3f497e9464b138ba3e779 Mon Sep 17 00:00:00 2001 From: HenrikJannsen Date: Mon, 28 Oct 2024 19:11:46 +0700 Subject: [PATCH 1/2] Revert "We did not get closed exceeding connections in maybeCloseExceedingConnections as we use getAllActiveConnections which has further down the call to `networkEnvelopeSocket.isClosed()` returning true, thus ignoring that connection for closing." This reverts commit d5a4d726606b2093beb0ad8439f9ea86f1071ce4. --- .../network/src/main/java/bisq/network/p2p/node/Connection.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network/network/src/main/java/bisq/network/p2p/node/Connection.java b/network/network/src/main/java/bisq/network/p2p/node/Connection.java index 7ae0693e5a..b2c36dcdac 100644 --- a/network/network/src/main/java/bisq/network/p2p/node/Connection.java +++ b/network/network/src/main/java/bisq/network/p2p/node/Connection.java @@ -318,7 +318,7 @@ AtomicInteger getSentMessageCounter() { } boolean isStopped() { - return shutdownStarted; + return shutdownStarted || networkEnvelopeSocket.isClosed() || Thread.currentThread().isInterrupted(); } From 065fac362912353743a754d2499330352d8bb886 Mon Sep 17 00:00:00 2001 From: HenrikJannsen Date: Mon, 28 Oct 2024 19:14:21 +0700 Subject: [PATCH 2/2] Do not close socket if send of receiveNextEnvelope methods fail. It will be handled by the client code anyway and has caused dangling connections. --- .../p2p/node/envelope/NetworkEnvelopeSocket.java | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/network/network/src/main/java/bisq/network/p2p/node/envelope/NetworkEnvelopeSocket.java b/network/network/src/main/java/bisq/network/p2p/node/envelope/NetworkEnvelopeSocket.java index cb9f7a4e2a..f737951254 100644 --- a/network/network/src/main/java/bisq/network/p2p/node/envelope/NetworkEnvelopeSocket.java +++ b/network/network/src/main/java/bisq/network/p2p/node/envelope/NetworkEnvelopeSocket.java @@ -39,22 +39,12 @@ public NetworkEnvelopeSocket(PeerSocket socket) { } public void send(NetworkEnvelope networkEnvelope) throws IOException { - try { - networkEnvelope.writeDelimitedTo(outputStream); - outputStream.flush(); - } catch (IOException e) { - close(); - throw e; - } + networkEnvelope.writeDelimitedTo(outputStream); + outputStream.flush(); } public bisq.network.protobuf.NetworkEnvelope receiveNextEnvelope() throws IOException { - try { - return bisq.network.protobuf.NetworkEnvelope.parseDelimitedFrom(inputStream); - } catch (IOException e) { - close(); - throw e; - } + return bisq.network.protobuf.NetworkEnvelope.parseDelimitedFrom(inputStream); } @Override