From 9c05025a8ef9c1dbfe2a9c8cc03fcad9d29a633e Mon Sep 17 00:00:00 2001 From: Alex Clayton Date: Wed, 13 May 2015 10:52:00 +0100 Subject: Make sure Stroke clears write buffer before disconnecting There was a bug with stroke where if I sent a large amount of messgaes (cica 1000) and then disconnected, not all the messages would be sent before storke handled the disconnect. It seems it did not fully lear the write buffer before closing the stream. This patch shoudl fix the error. It now only closses if the disconnecting flag is closed and the write buffer is closed. This should bring it into line with Swiften behaviour. Test-information: I had a simple stroke application that sent 1000 messages and then disconnected. Before the patch it would only send abut 80 or so of the messages before it got disconnected. After the patch it now sends all the messages before disconnecting. Change-Id: I6f56b25dcbabd16ee860dbf353f39559a77d6830 Signed-off-by: Alex Clayton diff --git a/src/com/isode/stroke/network/JavaConnection.java b/src/com/isode/stroke/network/JavaConnection.java index 34f332b..3560e83 100644 --- a/src/com/isode/stroke/network/JavaConnection.java +++ b/src/com/isode/stroke/network/JavaConnection.java @@ -76,7 +76,7 @@ public class JavaConnection extends Connection implements EventOwner { } handleConnected(false); - while (!disconnecting_) { + while (!disconnecting_ || isWriteNeeded()) { /* Something(s) happened. See what needs doing */ boolean writeNeeded = isWriteNeeded(); boolean readNeeded = selectionKey_.isReadable(); -- cgit v0.10.2-6-g49f6