[sr-dev] git:4.0: core: Fix connection leak with websockets

Hugh Waite hugh.waite at crocodile-rcs.com
Mon Sep 30 12:27:28 CEST 2013


Module: sip-router
Branch: 4.0
Commit: d5eadc90ebdb6460b43d304de86a37893263ce2d
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d5eadc90ebdb6460b43d304de86a37893263ce2d

Author: Hugh Waite <hugh.waite at crocodile-rcs.com>
Committer: Hugh Waite <hugh.waite at crocodile-rcs.com>
Date:   Thu Jul  4 10:30:51 2013 +0100

core: Fix connection leak with websockets

- Decrease connection ref count after using connection
(cherry picked from commit ffdae5987b99b9bfd39992d407a3a0a33aa772ab)

---

 forward.h |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/forward.h b/forward.h
index 17ac683..0e1d725 100644
--- a/forward.h
+++ b/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
 




More information about the sr-dev mailing list