[Red5devs] [PATCH 15 of 15] debugging closed connections

mabrek mabrek at gmail.com
Tue Aug 26 11:06:16 PDT 2008


diff -r 3e241327cb9a -r 06542742ce01 src/org/red5/server/net/rtmp/RTMPConnManager.java
--- a/src/org/red5/server/net/rtmp/RTMPConnManager.java	Mon Jul 21 11:37:55 2008 +0400
+++ b/src/org/red5/server/net/rtmp/RTMPConnManager.java	Fri Jul 25 16:56:02 2008 +0400
@@ -12,9 +12,13 @@
 import org.springframework.beans.BeansException;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class RTMPConnManager implements IRTMPConnManager,
 		ApplicationContextAware {
+	private static final Logger log = LoggerFactory.getLogger(RTMPConnManager.class);
+	
 	private ConcurrentMap<Integer, RTMPConnection> connMap = new ConcurrentHashMap<Integer, RTMPConnection>();
 
 	private ReadWriteLock lock = new ReentrantReadWriteLock();
@@ -43,6 +47,7 @@
 					}
 					offset++;
 				}
+				log.debug("Connection created, id: {}", conn.getId());
 			} finally {
 				lock.writeLock().unlock();
 			}
@@ -64,6 +69,7 @@
 	public RTMPConnection removeConnection(int clientId) {
 		lock.writeLock().lock();
 		try {
+			log.debug("Removing connection with id: {}", clientId);
 			return connMap.remove(clientId);
 		} finally {
 			lock.writeLock().unlock();
diff -r 3e241327cb9a -r 06542742ce01 src/org/red5/server/net/rtmp/RTMPConnection.java
--- a/src/org/red5/server/net/rtmp/RTMPConnection.java	Mon Jul 21 11:37:55 2008 +0400
+++ b/src/org/red5/server/net/rtmp/RTMPConnection.java	Fri Jul 25 16:56:02 2008 +0400
@@ -280,6 +280,7 @@
 				waitForHandshakeService.removeScheduledJob(waitForHandshakeJob);
 				waitForHandshakeJob = null;
 				waitForHandshakeService = null;
+				log.debug("Removed waitForHandshakeJob for: {}", getId());
 			}
 		}
 		return success;
diff -r 3e241327cb9a -r 06542742ce01 src/org/red5/server/net/rtmpt/RTMPTConnection.java
--- a/src/org/red5/server/net/rtmpt/RTMPTConnection.java	Mon Jul 21 11:37:55 2008 +0400
+++ b/src/org/red5/server/net/rtmpt/RTMPTConnection.java	Fri Jul 25 16:56:02 2008 +0400
@@ -112,6 +112,7 @@
 	/** {@inheritDoc} */
 	@Override
 	protected void onInactive() {
+		log.debug("Inactive connection id: {}, closing", getId());
 		close();
 		realClose();
 	}
diff -r 3e241327cb9a -r 06542742ce01 src/org/red5/server/net/rtmpt/RTMPTServlet.java
--- a/src/org/red5/server/net/rtmpt/RTMPTServlet.java	Mon Jul 21 11:37:55 2008 +0400
+++ b/src/org/red5/server/net/rtmpt/RTMPTServlet.java	Fri Jul 25 16:56:02 2008 +0400
@@ -288,16 +288,16 @@
 		skipData(req);
 
 		// TODO: should we evaluate the pathinfo?
-		RTMPTConnection client = createConnection();
-		client.setServlet(this);
-		if (client.getId() == 0) {
+		RTMPTConnection connection = createConnection();
+		connection.setServlet(this);
+		if (connection.getId() == 0) {
 			// no more clients are available for serving
 			returnMessage((byte) 0, resp);
 			return;
 		}
 
 		// Return connection id to client
-		returnMessage(client.getId() + "\n", resp);
+		returnMessage(connection.getId() + "\n", resp);
 	}
 
 	/**
@@ -320,7 +320,7 @@
 
 		RTMPTConnection connection = getClientConnection(req);
 		if (connection == null) {
-			handleBadRequest("Unknown client.", resp);
+			handleBadRequest("Close: unknown client with id: " + getClientId(req), resp);
 			return;
 		}
 		removeConnection(connection.getId());
@@ -349,7 +349,7 @@
 
 		RTMPTConnection connection = getClientConnection(req);
 		if (connection == null) {
-			handleBadRequest("Unknown client.", resp);
+			handleBadRequest("Send: unknown client with id: " + getClientId(req), resp);
 			return;
 		} else if (connection.getState().getState() == RTMP.STATE_DISCONNECTED) {
 			removeConnection(connection.getId());
@@ -407,7 +407,7 @@
 
 		RTMPTConnection connection = getClientConnection(req);
 		if (connection == null) {
-			handleBadRequest("Unknown client.", resp);
+			handleBadRequest("Idle: unknown client with id: " + getClientId(req), resp);
 			return;
 		} else if (connection.isClosing()) {
 			// Tell client to close the connection
@@ -504,7 +504,10 @@
 	}
 	
     protected RTMPTConnection getConnection(int clientId) {
-    	return (RTMPTConnection) rtmpConnManager.getConnection(clientId);
+		RTMPTConnection connection = (RTMPTConnection) rtmpConnManager.getConnection(clientId);
+		if (connection == null)
+			log.warn("Null connection for clientId: {}", clientId);
+		return connection;
     }
     
     protected RTMPTConnection createConnection() {





More information about the Red5devs mailing list