Selaa lähdekoodia

websocket: clean up ws structures without an active tcp connection

- GH #3236
Daniel-Constantin Mierla 3 vuotta sitten
vanhempi
commit
abe60832de
1 muutettua tiedostoa jossa 10 lisäystä ja 0 poistoa
  1. 10 0
      src/modules/websocket/ws_conn.c

+ 10 - 0
src/modules/websocket/ws_conn.c

@@ -679,6 +679,7 @@ void ws_timer(unsigned int ticks, void *param)
 	ws_connection_list_t rmlist;
 	ws_connection_t *wsc;
 	ws_connection_t *next;
+	struct tcp_connection *con = NULL;
 	ticks_t nticks;
 	int h;
 
@@ -695,6 +696,15 @@ void ws_timer(unsigned int ticks, void *param)
 				wsconn_detach_connection(wsc);
 				wsc->id_next = rmlist.head;
 				rmlist.head = wsc;
+			} else if(wsc->state != WS_S_REMOVING) {
+				con = tcpconn_get(wsc->id, 0, 0, 0, 0);
+				if(con == NULL) {
+					LM_DBG("ws structure without active tcp connection\n");
+					wsc->state = WS_S_REMOVING;
+					wsc->rmticks = get_ticks();
+				} else {
+					tcpconn_put(con);
+				}
 			}
 			wsc = next;
 		}