[sr-dev] git:5.5:f4ebe527: msrp: fix some tcpconn where memory was never cleaned up

Daniel-Constantin Mierla miconda at gmail.com
Fri Nov 5 08:51:22 CET 2021


Module: kamailio
Branch: 5.5
Commit: f4ebe527c25ecedb3caffa8a361b5c42a2dd6b88
URL: https://github.com/kamailio/kamailio/commit/f4ebe527c25ecedb3caffa8a361b5c42a2dd6b88

Author: Nacho Garcia Segovia <nacho.gs at zaleos.net>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2021-11-05T08:43:59+01:00

msrp: fix some tcpconn where memory was never cleaned up

Thanks to Jason Shugart at INdigital. Fix consist of caring of removing references to previously retrieved tcp connections. GH #2880

(cherry picked from commit bf371ccbfa1c89fefcd9d9322ae75189d97fc862)

---

Modified: src/modules/msrp/msrp_netio.c

---

Diff:  https://github.com/kamailio/kamailio/commit/f4ebe527c25ecedb3caffa8a361b5c42a2dd6b88.diff
Patch: https://github.com/kamailio/kamailio/commit/f4ebe527c25ecedb3caffa8a361b5c42a2dd6b88.patch

---

diff --git a/src/modules/msrp/msrp_netio.c b/src/modules/msrp/msrp_netio.c
index 92f7cf525b..859432aa6d 100644
--- a/src/modules/msrp/msrp_netio.c
+++ b/src/modules/msrp/msrp_netio.c
@@ -74,6 +74,7 @@ int msrp_relay(msrp_frame_t *mf)
 	char *l;
 	int port;
 	sr_event_param_t evp = {0};
+	int ret;
 
 	if(mf->buf.len>=MSRP_MAX_FRAME_SIZE-1)
 		return -1;
@@ -169,12 +170,17 @@ int msrp_relay(msrp_frame_t *mf)
 			wsev.len = p - reqbuf;
 			wsev.id = con->id;
 			evp.data = (void *)&wsev;
-			return sr_event_exec(SREV_TCP_WS_FRAME_OUT, &evp);
+			ret = sr_event_exec(SREV_TCP_WS_FRAME_OUT, &evp);
+			tcpconn_put(con);
+			return ret;
 		}
 		else if (tcp_send(dst, 0, reqbuf, p - reqbuf) < 0) {
 			LM_ERR("forwarding frame failed\n");
+			tcpconn_put(con);
 			return -1;
 		}
+
+		tcpconn_put(con);
 	}
 	else if (tcp_send(dst, 0, reqbuf, p - reqbuf) < 0) {
 			LM_ERR("forwarding frame failed\n");
@@ -195,6 +201,7 @@ int msrp_reply(msrp_frame_t *mf, str *code, str *text, str *xhdrs)
 	char *p;
 	char *l;
 	sr_event_param_t evp = {0};
+	int ret;
 
 	/* no reply for a reply */
 	if(mf->fline.msgtypeid==MSRP_REPLY)
@@ -301,7 +308,9 @@ int msrp_reply(msrp_frame_t *mf, str *code, str *text, str *xhdrs)
 		wsev.len = p - rplbuf;
 		wsev.id = con->id;
 		evp.data = (void *)&wsev;
-		return sr_event_exec(SREV_TCP_WS_FRAME_OUT, &evp);
+		ret = sr_event_exec(SREV_TCP_WS_FRAME_OUT, &evp);
+		tcpconn_put(con);
+		return ret;
 	}
 	else
 	if (tcp_send(&env->srcinfo, 0, rplbuf, p - rplbuf) < 0) {




More information about the sr-dev mailing list