From ab467b3d3e24eae2cf4caedc2f0088f9647c8355 Mon Sep 17 00:00:00 2001
From: akwizgran <akwizgran@users.sourceforge.net>
Date: Sun, 9 Nov 2014 18:03:24 +0000
Subject: [PATCH] Flush the output stream before rather than after waiting for
 packets.

See bug #27.
---
 .../src/org/briarproject/messaging/DuplexOutgoingSession.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/briar-core/src/org/briarproject/messaging/DuplexOutgoingSession.java b/briar-core/src/org/briarproject/messaging/DuplexOutgoingSession.java
index e5db2519ad..a656c94587 100644
--- a/briar-core/src/org/briarproject/messaging/DuplexOutgoingSession.java
+++ b/briar-core/src/org/briarproject/messaging/DuplexOutgoingSession.java
@@ -106,11 +106,11 @@ class DuplexOutgoingSession implements MessagingSession, EventListener {
 			// Write packets until interrupted
 			try {
 				while(!interrupted) {
+					// Flush the stream if it's going to be idle
+					if(writerTasks.isEmpty()) out.flush();
 					ThrowingRunnable<IOException> task = writerTasks.take();
 					if(task == CLOSE) break;
 					task.run();
-					// Flush the stream if it's going to be idle
-					if(writerTasks.isEmpty()) out.flush();
 				}
 				out.flush();
 			} catch(InterruptedException e) {
-- 
GitLab