Commit 7f099845 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/trunk@1406 b35dd754-fafc-0310-a699-88a17e54d16e
parent 26b40771
......@@ -88,6 +88,8 @@ public class SocketConnection implements Connection {
}
try {
synchronized (writer) {
// Register that we started sending data on the connection
SocketSendingTracker.getInstance().socketStartedSending(socket);
writer.write(" ");
writer.flush();
}
......@@ -96,6 +98,10 @@ public class SocketConnection implements Connection {
Log.warn("Closing no longer valid connection" + "\n" + this.toString(), e);
close();
}
finally {
// Register that we finished sending data on the connection
SocketSendingTracker.getInstance().socketFinishedSending(socket);
}
return !isClosed();
}
......@@ -197,6 +203,8 @@ public class SocketConnection implements Connection {
}
synchronized (writer) {
try {
// Register that we started sending data on the connection
SocketSendingTracker.getInstance().socketStartedSending(socket);
writer.write("</stream:stream>");
if (flashClient) {
writer.write('\0');
......@@ -204,6 +212,10 @@ public class SocketConnection implements Connection {
xmlSerializer.flush();
}
catch (IOException e) {}
finally {
// Register that we finished sending data on the connection
SocketSendingTracker.getInstance().socketFinishedSending(socket);
}
}
}
catch (Exception e) {
......@@ -236,6 +248,8 @@ public class SocketConnection implements Connection {
boolean errorDelivering = false;
synchronized (writer) {
try {
// Register that we started sending data on the connection
SocketSendingTracker.getInstance().socketStartedSending(socket);
xmlSerializer.write(packet.getElement());
if (flashClient) {
writer.write('\0');
......@@ -246,6 +260,10 @@ public class SocketConnection implements Connection {
Log.debug("Error delivering packet" + "\n" + this.toString(), e);
errorDelivering = true;
}
finally {
// Register that we finished sending data on the connection
SocketSendingTracker.getInstance().socketFinishedSending(socket);
}
}
if (errorDelivering) {
close();
......@@ -270,6 +288,8 @@ public class SocketConnection implements Connection {
boolean errorDelivering = false;
synchronized (writer) {
try {
// Register that we started sending data on the connection
SocketSendingTracker.getInstance().socketStartedSending(socket);
writer.write(text);
if (flashClient) {
writer.write('\0');
......@@ -280,6 +300,10 @@ public class SocketConnection implements Connection {
Log.debug("Error delivering raw text" + "\n" + this.toString(), e);
errorDelivering = true;
}
finally {
// Register that we finished sending data on the connection
SocketSendingTracker.getInstance().socketFinishedSending(socket);
}
}
if (errorDelivering) {
close();
......
......@@ -230,6 +230,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
isStarted = true;
serverName = server.getServerInfo().getName();
createSocket();
SocketSendingTracker.getInstance().start();
}
public void stop() {
......@@ -250,6 +251,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
serverSocketThread.shutdown();
serverSocketThread = null;
}
SocketSendingTracker.getInstance().shutdown();
serverName = null;
}
}
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