Browse code

websocket: clean up ws structures without an active tcp connection

- GH #3236

(cherry picked from commit abe60832de46796a1395a75a67753c1a12a1ec0a)

Daniel-Constantin Mierla authored on 16/09/2022 12:51:31
Showing 1 changed files
... ...
@@ -679,6 +679,7 @@ void ws_timer(unsigned int ticks, void *param)
679 679
 	ws_connection_list_t rmlist;
680 680
 	ws_connection_t *wsc;
681 681
 	ws_connection_t *next;
682
+	struct tcp_connection *con = NULL;
682 683
 	ticks_t nticks;
683 684
 	int h;
684 685
 
... ...
@@ -695,6 +696,15 @@ void ws_timer(unsigned int ticks, void *param)
695 696
 				wsconn_detach_connection(wsc);
696 697
 				wsc->id_next = rmlist.head;
697 698
 				rmlist.head = wsc;
699
+			} else if(wsc->state != WS_S_REMOVING) {
700
+				con = tcpconn_get(wsc->id, 0, 0, 0, 0);
701
+				if(con == NULL) {
702
+					LM_DBG("ws structure without active tcp connection\n");
703
+					wsc->state = WS_S_REMOVING;
704
+					wsc->rmticks = get_ticks();
705
+				} else {
706
+					tcpconn_put(con);
707
+				}
698 708
 			}
699 709
 			wsc = next;
700 710
 		}