Skip to content

Commit

Permalink
msrp: fix some tcpconn where memory was never cleaned up
Browse files Browse the repository at this point in the history
Thanks to Jason Shugart at INdigital. Fix consist of caring of removing references to previously retrieved tcp connections. GH #2880

(cherry picked from commit bf371cc)
(cherry picked from commit f4ebe52)
  • Loading branch information
NGSegovia authored and miconda committed Dec 6, 2021
1 parent 88ec70c commit dccc47c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/modules/msrp/msrp_netio.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand All @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit dccc47c

Please sign in to comment.