Browse Source

core: Fix connection leak with websockets

- Decrease connection ref count after using connection
Hugh Waite 12 years ago
parent
commit
ffdae5987b
1 changed files with 6 additions and 3 deletions
  1. 6 3
      forward.h

+ 6 - 3
forward.h

@@ -134,6 +134,7 @@ static inline int msg_send(struct dest_info* dst, char* buf, int len)
 	union sockaddr_union local_addr;
 	struct tcp_connection *con = NULL;
 	struct ws_event_info wsev;
+	int ret;
 #endif
 	
 	outb.s = buf;
@@ -162,13 +163,13 @@ static inline int msg_send(struct dest_info* dst, char* buf, int len)
 			con = tcpconn_get(dst->id, 0, 0, 0, 0);
 		else {
 			LM_CRIT("BUG: msg_send called with null_id & to\n");
-			return -1;
+			goto error;
 		}
 
 		if (con == NULL)
 		{
 			LM_WARN("TCP/TLS connection for WebSocket could not be found\n");
-			return -1;
+			goto error;
 		}
 
 		memset(&wsev, 0, sizeof(ws_event_info_t));
@@ -176,7 +177,9 @@ static inline int msg_send(struct dest_info* dst, char* buf, int len)
 		wsev.buf = outb.s;
 		wsev.len = outb.len;
 		wsev.id = con->id;
-		return sr_event_exec(SREV_TCP_WS_FRAME_OUT, (void *) &wsev);
+		ret = sr_event_exec(SREV_TCP_WS_FRAME_OUT, (void *) &wsev);
+		tcpconn_put(con);
+		return ret;
 	}
 #endif