Skip to content

Commit

Permalink
media_exchange: properly handle internally generated timeouts
Browse files Browse the repository at this point in the history
(cherry picked from commit de5347c)
  • Loading branch information
razvancrainea committed Feb 28, 2023
1 parent e4d3be0 commit 4569c3c
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions modules/media_exchange/media_exchange.c
Original file line number Diff line number Diff line change
Expand Up @@ -1219,9 +1219,11 @@ static void handle_media_session_negative(struct media_session_leg *msl)
int dlg_leg;
str sbody, *body;

/* if it is a fork, there's nothing to do */
if (msl->type != MEDIA_SESSION_TYPE_EXCHANGE)
/* if it is a fork, there's nothing to do, just unref to release */
if (msl->type != MEDIA_SESSION_TYPE_EXCHANGE) {
MSL_UNREF(msl);
return;
}

/* if no transaction is hanging, we don't have anything to do */
if (!p)
Expand Down Expand Up @@ -1409,6 +1411,7 @@ static int b2b_media_notify(struct sip_msg *msg, str *key, int type,
{
struct media_session_leg *msl = (struct media_session_leg *)param;
int initial_state;
struct cell *trans;

if (type == B2B_REPLY) {
if (msg->REPLY_STATUS < 200) /* don't care about provisional replies */
Expand All @@ -1419,18 +1422,27 @@ static int b2b_media_notify(struct sip_msg *msg, str *key, int type,
return -1;
}
switch (get_cseq(msg)->method_id) {
case METHOD_UNDEF:
trans = media_tm.t_gett();
if (!is_invite(trans)) {
LM_INFO("timeout for non-INVITE (callid=%.*s)\n",
msl->ms->dlg->callid.len, msl->ms->dlg->callid.s);
}
/* fall through */

case METHOD_INVITE:
MEDIA_LEG_LOCK(msl);
initial_state = msl->state;
MEDIA_LEG_UNLOCK(msl);
if (msg->REPLY_STATUS >= 300) {
LM_ERR("could not stream media due to negative reply %d\n",
msg->REPLY_STATUS);
LM_ERR("could not stream media due to negative reply %d (callid=%.*s)\n",
msg->REPLY_STATUS, msl->ms->dlg->callid.len, msl->ms->dlg->callid.s);
goto terminate;
}
media_session_req(msl, ACK, NULL);
if (handle_media_session_reply(msl, msg) < 0) {
LM_ERR("could not establish media exchange!\n");
LM_ERR("could not establish media exchange (callid=%.*s)!\n",
msl->ms->dlg->callid.len, msl->ms->dlg->callid.s);
goto terminate;
}
/* successfully processed reply */
Expand All @@ -1439,8 +1451,9 @@ static int b2b_media_notify(struct sip_msg *msg, str *key, int type,
/* nothing to do now, just absorb! */
return 0;
default:
LM_DBG("unexpected reply with status %d for %.*s\n",
msg->REPLY_STATUS, key->len, key->s);
LM_DBG("unexpected reply with status %d for %.*s (callid=%.*s)\n",
msg->REPLY_STATUS, key->len, key->s,
msl->ms->dlg->callid.len, msl->ms->dlg->callid.s);
return -1;
}
return 0;
Expand All @@ -1453,7 +1466,6 @@ static int b2b_media_notify(struct sip_msg *msg, str *key, int type,
/* this is the initial leg, not a re-invite */
MEDIA_LEG_UNLOCK(msl);
handle_media_session_negative(msl);
MSL_UNREF(msl);
} else {
MEDIA_LEG_UNLOCK(msl);
}
Expand Down

0 comments on commit 4569c3c

Please sign in to comment.