Commit dd8f33b5 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Sending </stream:stream> is now synchronous. JM-975

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@7096 b35dd754-fafc-0310-a699-88a17e54d16e
parent eb59a109
......@@ -128,7 +128,7 @@ public class NIOConnection implements Connection {
synchronized (this) {
if (!isClosed()) {
try {
deliverRawText(flashClient ? "</flash:stream>" : "</stream:stream>");
deliverRawText(flashClient ? "</flash:stream>" : "</stream:stream>", false);
} catch (Exception e) {
// Ignore
}
......@@ -147,19 +147,6 @@ public class NIOConnection implements Connection {
close();
}
/**
* Forces the connection to be closed immediately no matter if closing the socket takes
* a long time. This method should only be called from {@link org.jivesoftware.wildfire.net.SocketSendingTracker} when
* sending data over the socket has taken a long time and we need to close the socket, discard
* the connection and its ioSession.
*/
private void forceClose() {
closeConnection();
// Notify the close listeners so that the SessionManager can send unavailable
// presences if required.
notifyCloseListeners();
}
private void closeConnection() {
ioSession.close();
}
......@@ -227,6 +214,11 @@ public class NIOConnection implements Connection {
}
public void deliverRawText(String text) {
// Deliver the packet in asynchronous mode
deliverRawText(text, true);
}
private void deliverRawText(String text, boolean asynchronous) {
if (!isClosed()) {
ByteBuffer buffer = ByteBuffer.allocate(text.length());
buffer.setAutoExpand(true);
......@@ -240,8 +232,13 @@ public class NIOConnection implements Connection {
buffer.put((byte) '\0');
}
buffer.flip();
if (asynchronous) {
ioSession.write(buffer);
}
else {
ioSession.write(buffer).join();
}
}
catch (Exception e) {
Log.debug("Error delivering raw text" + "\n" + this.toString(), e);
errorDelivering = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment