Prevent immediate tsx termination upon transport error (#3805)

This commit is contained in:
sauwming 2023-12-18 11:56:43 +08:00 committed by GitHub
parent 48f3723d71
commit ca2e450edf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -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.
*/
@ -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);