Skip to content

Commit

Permalink
Fix sip transaction to send pending message (#2471)
Browse files Browse the repository at this point in the history
  • Loading branch information
sauwming committed Jul 20, 2020
1 parent 973bb67 commit 92d2e8d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
32 changes: 32 additions & 0 deletions pjsip/src/pjsip/sip_transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -2042,6 +2042,38 @@ static void transport_callback(void *token, pjsip_tx_data *tdata,
*/
pj_grp_lock_acquire(tsx->grp_lock);
tsx->transport_flag &= ~(TSX_HAS_PENDING_TRANSPORT);

if (sent > 0) {
/* Pending destroy? */
if (tsx->transport_flag & TSX_HAS_PENDING_DESTROY) {
tsx_set_state( tsx, PJSIP_TSX_STATE_DESTROYED,
PJSIP_EVENT_UNKNOWN, NULL, 0 );
pj_grp_lock_release(tsx->grp_lock);
return;
}

/* Need to transmit a message? */
if (tsx->transport_flag & TSX_HAS_PENDING_SEND) {
tsx->transport_flag &= ~(TSX_HAS_PENDING_SEND);
tsx_send_msg(tsx, tsx->last_tx);
}

/* Need to reschedule retransmission?
* Note that when sending a pending message above, tsx_send_msg()
* may set the flag TSX_HAS_PENDING_TRANSPORT.
* Please refer to ticket #1875.
*/
if (tsx->transport_flag & TSX_HAS_PENDING_RESCHED &&
!(tsx->transport_flag & TSX_HAS_PENDING_TRANSPORT))
{
tsx->transport_flag &= ~(TSX_HAS_PENDING_RESCHED);

/* Only update when transport turns out to be unreliable. */
if (!tsx->is_reliable) {
tsx_resched_retransmission(tsx);
}
}
}
pj_grp_lock_release(tsx->grp_lock);

if (sent < 0) {
Expand Down
6 changes: 5 additions & 1 deletion pjsip/src/pjsip/sip_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,11 @@ PJ_DEF(pj_status_t) pjsip_tx_data_clone(const pjsip_tx_data *src,
if (src->msg->body)
msg->body = pjsip_msg_body_clone(dst->pool, src->msg->body);

dst->is_pending = src->is_pending;
/* We shouldn't copy is_pending since it's src's internal state,
* indicating that it's currently being sent by the transport.
* While the cloned tdata is of course not.
*/
//dst->is_pending = src->is_pending;

PJ_LOG(5,(THIS_FILE,
"Tx data %s cloned",
Expand Down

0 comments on commit 92d2e8d

Please sign in to comment.