Flush the output stream before rather than after waiting for packets.

See bug #27.
This commit is contained in:
akwizgran
2014-11-09 18:03:24 +00:00
parent 4b92de619c
commit ab467b3d3e

View File

@@ -106,11 +106,11 @@ class DuplexOutgoingSession implements MessagingSession, EventListener {
// Write packets until interrupted // Write packets until interrupted
try { try {
while(!interrupted) { while(!interrupted) {
// Flush the stream if it's going to be idle
if(writerTasks.isEmpty()) out.flush();
ThrowingRunnable<IOException> task = writerTasks.take(); ThrowingRunnable<IOException> task = writerTasks.take();
if(task == CLOSE) break; if(task == CLOSE) break;
task.run(); task.run();
// Flush the stream if it's going to be idle
if(writerTasks.isEmpty()) out.flush();
} }
out.flush(); out.flush();
} catch(InterruptedException e) { } catch(InterruptedException e) {