Skip to content

Commit

Permalink
rtp_relay: fix invalid contexts leaked in list
Browse files Browse the repository at this point in the history
When a session would have been established on a provisional reply with
body (i.e. 183), the rtp contexts would have been stored in the list.
However, if the call would not establish (with a 200 OK), there would be
no one removing it from the list, even though the context was released -
this resulted in unexpected and almost impossible to track down invalid
memory usage.
The current patch makes sure that the context is removed from the list
if the call does not establish.

Many thanks to Rob Moore, Daniel Bryars and Steven Ayre from Dubber for
pushing an enormous amount of time into troubleshooting and debugging
this, as well as to Liviu Chircu for guiding the troubleshooting!

(cherry picked from commit d6ef279)
  • Loading branch information
razvancrainea committed Sep 4, 2023
1 parent 98a8b03 commit f7defa0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions modules/rtp_relay/rtp_relay_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1809,8 +1809,17 @@ static void rtp_relay_ctx_initial_cb(struct cell* t, int type, struct tmcb_param
rtp_sess_disabled(sess), rtp_sess_pending(sess));
goto end;
}
handle_rtp_relay_ctx_leg_reply(ctx, p->rpl, sess, RTP_RELAY_CALLEE);
rtp_relay_ctx_leg_reply(ctx, p->rpl, t, sess, RTP_RELAY_CALLEE);
switch (handle_rtp_relay_ctx_leg_reply(ctx, p->rpl, sess, RTP_RELAY_CALLEE)) {
case 0:
rtp_relay_ctx_leg_reply(ctx, p->rpl, t, sess, RTP_RELAY_CALLEE);
break;
case 1:
lock_start_write(rtp_relay_contexts_lock);
if (list_is_valid(&ctx->list))
list_del(&ctx->list);
lock_stop_write(rtp_relay_contexts_lock);
break;
}
break;
case TMCB_REQUEST_FWDED:
sess = rtp_relay_get_sess(ctx, rtp_relay_ctx_branch());
Expand Down

0 comments on commit f7defa0

Please sign in to comment.