Skip to content

Commit

Permalink
Merge pull request #2964 from HenrikJannsen/do-not-close-socket-from-…
Browse files Browse the repository at this point in the history
…NetworkEnvelopeSocket

Do not close socket from network envelope socket
  • Loading branch information
HenrikJannsen authored Oct 29, 2024
2 parents 89eb239 + 065fac3 commit cc4a154
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ AtomicInteger getSentMessageCounter() {
}

boolean isStopped() {
return shutdownStarted;
return shutdownStarted || networkEnvelopeSocket.isClosed() || Thread.currentThread().isInterrupted();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cc4a154

Please sign in to comment.