From 7734a62c3e846e18a5582df226dabab682032b3c Mon Sep 17 00:00:00 2001 From: akwizgran <michael@briarproject.org> Date: Thu, 10 May 2018 12:29:45 +0100 Subject: [PATCH] Interrupt outgoing session when incoming session ends. --- .../bramble/plugin/ConnectionManagerImpl.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bramble-core/src/main/java/org/briarproject/bramble/plugin/ConnectionManagerImpl.java b/bramble-core/src/main/java/org/briarproject/bramble/plugin/ConnectionManagerImpl.java index cc188a3eb9..99574a8726 100644 --- a/bramble-core/src/main/java/org/briarproject/bramble/plugin/ConnectionManagerImpl.java +++ b/bramble-core/src/main/java/org/briarproject/bramble/plugin/ConnectionManagerImpl.java @@ -300,8 +300,8 @@ class ConnectionManagerImpl implements ConnectionManager { } private void disposeReader(boolean exception, boolean recognised) { - if (exception && outgoingSession != null) - outgoingSession.interrupt(); + // Interrupt the outgoing session so it finishes cleanly + if (outgoingSession != null) outgoingSession.interrupt(); try { reader.dispose(exception, recognised); } catch (IOException e) { @@ -310,6 +310,8 @@ class ConnectionManagerImpl implements ConnectionManager { } private void disposeWriter(boolean exception) { + // Interrupt the incoming session if an exception occurred, + // otherwise wait for the end of stream marker if (exception && incomingSession != null) incomingSession.interrupt(); try { @@ -407,8 +409,8 @@ class ConnectionManagerImpl implements ConnectionManager { } private void disposeReader(boolean exception, boolean recognised) { - if (exception && outgoingSession != null) - outgoingSession.interrupt(); + // Interrupt the outgoing session so it finishes cleanly + if (outgoingSession != null) outgoingSession.interrupt(); try { reader.dispose(exception, recognised); } catch (IOException e) { @@ -417,6 +419,8 @@ class ConnectionManagerImpl implements ConnectionManager { } private void disposeWriter(boolean exception) { + // Interrupt the incoming session if an exception occurred, + // otherwise wait for the end of stream marker if (exception && incomingSession != null) incomingSession.interrupt(); try { -- GitLab