Skip to content

Commit

Permalink
Prevent immediate tsx termination upon transport error (#3805)
Browse files Browse the repository at this point in the history
  • Loading branch information
sauwming authored Dec 18, 2023
1 parent 48f3723 commit ca2e450
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pjsip/src/pjsip/sip_transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -2187,11 +2187,15 @@ static void send_msg_callback( pjsip_send_state *send_state,
else
sc = PJSIP_SC_TSX_TRANSPORT_ERROR;

/* Terminate transaction, if it's not already terminated. */
tsx_set_status_code(tsx, sc, &err);
if (tsx->state != PJSIP_TSX_STATE_TERMINATED &&
/* We terminate the transaction for 502 error. For 503,
* we will retry it.
* See https://github.com/pjsip/pjproject/pull/3805
*/
if (sc == PJSIP_SC_BAD_GATEWAY &&
tsx->state != PJSIP_TSX_STATE_TERMINATED &&
tsx->state != PJSIP_TSX_STATE_DESTROYED)
{
tsx_set_status_code(tsx, sc, &err);
/* Set tsx state to TERMINATED, but release the lock
* when invoking the callback, to avoid deadlock.
*/
Expand All @@ -2204,6 +2208,7 @@ static void send_msg_callback( pjsip_send_state *send_state,
*/
else if (tsx->transport_flag & TSX_HAS_PENDING_DESTROY)
{
tsx_set_status_code(tsx, sc, &err);
tsx_set_state( tsx, PJSIP_TSX_STATE_DESTROYED,
PJSIP_EVENT_TRANSPORT_ERROR,
send_state->tdata, 0);
Expand Down

0 comments on commit ca2e450

Please sign in to comment.