Skip to content

Commit

Permalink
Handle case when provisional response is sent after a final one (#2350)
Browse files Browse the repository at this point in the history
Handle case when provisional response is sent after a final one
- If 100rel is required, prevent retransmission if the initial send fails, since the retransmission will cause a crash later.
- Otherwise, return error instead of asserting in sip_transaction
  • Loading branch information
sauwming committed Mar 20, 2020
1 parent 2ea82e9 commit e1edb64
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
11 changes: 9 additions & 2 deletions pjsip/src/pjsip-ua/sip_100rel.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,14 @@ static void on_retransmit(pj_timer_heap_t *timer_heap,
final = tdata->msg->line.status.code >= 200;

if (dd->uas_state->retransmit_count == 1) {
pjsip_tsx_send_msg(dd->inv->invite_tsx, tdata);
pj_status_t status;

status = pjsip_tsx_send_msg(dd->inv->invite_tsx, tdata);
if (status != PJ_SUCCESS) {
PJ_PERROR(3, (THIS_FILE, status,
"Failed to send message"));
return;
}
} else {
pjsip_tsx_retransmit_no_state(dd->inv->invite_tsx, tdata);
}
Expand Down Expand Up @@ -809,7 +816,7 @@ PJ_DEF(pj_status_t) pjsip_100rel_tx_response(pjsip_inv_session *inv,
char rseq_str[32];
pj_str_t rseq;
tx_data_list_t *tl;

/* Create UAS state if we don't have one */
if (dd->uas_state == NULL) {
dd->uas_state = PJ_POOL_ZALLOC_T(inv->dlg->pool,
Expand Down
7 changes: 4 additions & 3 deletions pjsip/src/pjsip/sip_transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -3273,10 +3273,11 @@ static pj_status_t tsx_on_state_completed_uas( pjsip_transaction *tsx,
}

} else {
/* Ignore request to transmit. */
PJ_ASSERT_RETURN(event->type == PJSIP_EVENT_TX_MSG &&
event->body.tx_msg.tdata == tsx->last_tx,
PJ_ASSERT_RETURN(event->type == PJSIP_EVENT_TX_MSG,
PJ_EINVALIDOP);
/* Ignore request to transmit a new message. */
if (event->body.tx_msg.tdata != tsx->last_tx)
return PJ_EINVALIDOP;
}

return PJ_SUCCESS;
Expand Down

0 comments on commit e1edb64

Please sign in to comment.