Commit be674144 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Added tracking of sending operations. JM-297


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/branches/jive_messenger_2_1_branch@1405 b35dd754-fafc-0310-a699-88a17e54d16e
parent 3ad9b87a
...@@ -88,6 +88,8 @@ public class SocketConnection implements Connection { ...@@ -88,6 +88,8 @@ public class SocketConnection implements Connection {
} }
try { try {
synchronized (writer) { synchronized (writer) {
// Register that we started sending data on the connection
SocketSendingTracker.getInstance().socketStartedSending(socket);
writer.write(" "); writer.write(" ");
writer.flush(); writer.flush();
} }
...@@ -96,6 +98,10 @@ public class SocketConnection implements Connection { ...@@ -96,6 +98,10 @@ public class SocketConnection implements Connection {
Log.warn("Closing no longer valid connection" + "\n" + this.toString(), e); Log.warn("Closing no longer valid connection" + "\n" + this.toString(), e);
close(); close();
} }
finally {
// Register that we finished sending data on the connection
SocketSendingTracker.getInstance().socketFinishedSending(socket);
}
return !isClosed(); return !isClosed();
} }
...@@ -197,6 +203,8 @@ public class SocketConnection implements Connection { ...@@ -197,6 +203,8 @@ public class SocketConnection implements Connection {
} }
synchronized (writer) { synchronized (writer) {
try { try {
// Register that we started sending data on the connection
SocketSendingTracker.getInstance().socketStartedSending(socket);
writer.write("</stream:stream>"); writer.write("</stream:stream>");
if (flashClient) { if (flashClient) {
writer.write('\0'); writer.write('\0');
...@@ -204,6 +212,10 @@ public class SocketConnection implements Connection { ...@@ -204,6 +212,10 @@ public class SocketConnection implements Connection {
xmlSerializer.flush(); xmlSerializer.flush();
} }
catch (IOException e) {} catch (IOException e) {}
finally {
// Register that we finished sending data on the connection
SocketSendingTracker.getInstance().socketFinishedSending(socket);
}
} }
} }
catch (Exception e) { catch (Exception e) {
...@@ -236,6 +248,8 @@ public class SocketConnection implements Connection { ...@@ -236,6 +248,8 @@ public class SocketConnection implements Connection {
boolean errorDelivering = false; boolean errorDelivering = false;
synchronized (writer) { synchronized (writer) {
try { try {
// Register that we started sending data on the connection
SocketSendingTracker.getInstance().socketStartedSending(socket);
xmlSerializer.write(packet.getElement()); xmlSerializer.write(packet.getElement());
if (flashClient) { if (flashClient) {
writer.write('\0'); writer.write('\0');
...@@ -246,6 +260,10 @@ public class SocketConnection implements Connection { ...@@ -246,6 +260,10 @@ public class SocketConnection implements Connection {
Log.debug("Error delivering packet" + "\n" + this.toString(), e); Log.debug("Error delivering packet" + "\n" + this.toString(), e);
errorDelivering = true; errorDelivering = true;
} }
finally {
// Register that we finished sending data on the connection
SocketSendingTracker.getInstance().socketFinishedSending(socket);
}
} }
if (errorDelivering) { if (errorDelivering) {
close(); close();
......
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