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 { ...@@ -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();
...@@ -270,6 +288,8 @@ public class SocketConnection implements Connection { ...@@ -270,6 +288,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);
writer.write(text); writer.write(text);
if (flashClient) { if (flashClient) {
writer.write('\0'); writer.write('\0');
...@@ -280,6 +300,10 @@ public class SocketConnection implements Connection { ...@@ -280,6 +300,10 @@ public class SocketConnection implements Connection {
Log.debug("Error delivering raw text" + "\n" + this.toString(), e); Log.debug("Error delivering raw text" + "\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();
......
...@@ -230,6 +230,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana ...@@ -230,6 +230,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
isStarted = true; isStarted = true;
serverName = server.getServerInfo().getName(); serverName = server.getServerInfo().getName();
createSocket(); createSocket();
SocketSendingTracker.getInstance().start();
} }
public void stop() { public void stop() {
...@@ -250,6 +251,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana ...@@ -250,6 +251,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
serverSocketThread.shutdown(); serverSocketThread.shutdown();
serverSocketThread = null; serverSocketThread = null;
} }
SocketSendingTracker.getInstance().shutdown();
serverName = null; 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