浏览代码

xmpp: shift head of connection list when first is closed

(cherry picked from commit ca4083f37326188cc5c64a148854b239234515df)
Daniel-Constantin Mierla 9 年之前
父节点
当前提交
936baa97ec
共有 1 个文件被更改,包括 8 次插入4 次删除
  1. 8 4
      modules/xmpp/xmpp_server.c

+ 8 - 4
modules/xmpp/xmpp_server.c

@@ -451,7 +451,7 @@ int xmpp_server_child_process(int data_pipe)
 	int listen_fd;
 	fd_set fdset;
 	struct xmpp_connection *conn;
-	
+
 	snprintf(local_secret, sizeof(local_secret), "%s", random_secret());
 
 	while ((listen_fd = net_listen(xmpp_domain, xmpp_port)) < 0) {
@@ -463,13 +463,17 @@ int xmpp_server_child_process(int data_pipe)
 		FD_ZERO(&fdset);
 		FD_SET(data_pipe, &fdset);
 		FD_SET(listen_fd, &fdset);
-		
+
 		/* check for dead connections */
 		for (conn = conn_list; conn; ) {
 			struct xmpp_connection *next = conn->next;
 
-			if (conn->type == CONN_DEAD)
+			if (conn->type == CONN_DEAD) {
+				if(conn == conn_list) {
+					conn_list = next;
+				}
 				conn_free(conn);
+			}
 			conn = next;
 		}
 
@@ -488,7 +492,7 @@ int xmpp_server_child_process(int data_pipe)
 				} else {
 					conn->type = CONN_DEAD;
 				}
-			}		
+			}
 
 			if (conn->fd != -1)
 				FD_SET(conn->fd, &fdset);