Changeset 4258 for pjproject/trunk


Ignore:
Timestamp:
Sep 18, 2012 8:39:46 AM (12 years ago)
Author:
ming
Message:

Fixed #1583: Unexpected SIP message transmission after transaction has timed-out

Location:
pjproject/trunk/pjsip/src/pjsip
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsip/sip_transport_tcp.c

    r3553 r4258  
    7474    PJ_DECL_LIST_MEMBER(struct delayed_tdata); 
    7575    pjsip_tx_data_op_key    *tdata_op_key; 
     76    pj_time_val              timeout; 
    7677}; 
    7778 
     
    650651static void tcp_flush_pending_tx(struct tcp_transport *tcp) 
    651652{ 
     653    pj_time_val now; 
     654 
     655    pj_gettickcount(&now); 
    652656    pj_lock_acquire(tcp->base.lock); 
    653657    while (!pj_list_empty(&tcp->delayed_list)) { 
     
    663667        tdata = pending_tx->tdata_op_key->tdata; 
    664668        op_key = (pj_ioqueue_op_key_t*)pending_tx->tdata_op_key; 
     669 
     670        if (pending_tx->timeout.sec > 0 && 
     671            PJ_TIME_VAL_GT(now, pending_tx->timeout)) 
     672        { 
     673            on_data_sent(tcp->asock, op_key, -PJ_ETIMEDOUT); 
     674            continue; 
     675        } 
    665676 
    666677        /* send! */ 
     
    11231134             * connect() is still in progress. Put the transmit data to 
    11241135             * the delayed list. 
     1136             * Starting from #1583 (https://trac.pjsip.org/repos/ticket/1583), 
     1137             * we also add timeout value for the transmit data. When the 
     1138             * connect() is completed, the timeout value will be checked to 
     1139             * determine whether the transmit data needs to be sent. 
    11251140             */ 
    1126             delayed_tdata = PJ_POOL_ALLOC_T(tdata->pool,  
    1127                                             struct delayed_tdata); 
     1141            delayed_tdata = PJ_POOL_ZALLOC_T(tdata->pool,  
     1142                                             struct delayed_tdata); 
    11281143            delayed_tdata->tdata_op_key = &tdata->op_key; 
     1144            if (tdata->msg && tdata->msg->type == PJSIP_REQUEST_MSG) { 
     1145                pj_gettickcount(&delayed_tdata->timeout); 
     1146                delayed_tdata->timeout.msec += pjsip_cfg()->tsx.td; 
     1147                pj_time_val_normalize(&delayed_tdata->timeout); 
     1148            } 
    11291149 
    11301150            pj_list_push_back(&tcp->delayed_list, delayed_tdata); 
  • pjproject/trunk/pjsip/src/pjsip/sip_transport_tls.c

    r4146 r4258  
    7272    PJ_DECL_LIST_MEMBER(struct delayed_tdata); 
    7373    pjsip_tx_data_op_key    *tdata_op_key; 
     74    pj_time_val              timeout; 
    7475}; 
    7576 
     
    648649static void tls_flush_pending_tx(struct tls_transport *tls) 
    649650{ 
     651    pj_time_val now; 
     652 
     653    pj_gettickcount(&now); 
    650654    pj_lock_acquire(tls->base.lock); 
    651655    while (!pj_list_empty(&tls->delayed_list)) { 
     
    661665        tdata = pending_tx->tdata_op_key->tdata; 
    662666        op_key = (pj_ioqueue_op_key_t*)pending_tx->tdata_op_key; 
     667 
     668        if (pending_tx->timeout.sec > 0 && 
     669            PJ_TIME_VAL_GT(now, pending_tx->timeout)) 
     670        { 
     671            on_data_sent(tls->ssock, op_key, -PJ_ETIMEDOUT); 
     672            continue; 
     673        } 
    663674 
    664675        /* send! */ 
     
    12181229             * connect() is still in progress. Put the transmit data to 
    12191230             * the delayed list. 
     1231             * Starting from #1583 (https://trac.pjsip.org/repos/ticket/1583), 
     1232             * we also add timeout value for the transmit data. When the 
     1233             * connect() is completed, the timeout value will be checked to 
     1234             * determine whether the transmit data needs to be sent. 
    12201235             */ 
    1221             delayed_tdata = PJ_POOL_ALLOC_T(tdata->pool,  
    1222                                             struct delayed_tdata); 
     1236            delayed_tdata = PJ_POOL_ZALLOC_T(tdata->pool,  
     1237                                             struct delayed_tdata); 
    12231238            delayed_tdata->tdata_op_key = &tdata->op_key; 
     1239            if (tdata->msg && tdata->msg->type == PJSIP_REQUEST_MSG) { 
     1240                pj_gettickcount(&delayed_tdata->timeout); 
     1241                delayed_tdata->timeout.msec += pjsip_cfg()->tsx.td; 
     1242                pj_time_val_normalize(&delayed_tdata->timeout); 
     1243            } 
    12241244 
    12251245            pj_list_push_back(&tls->delayed_list, delayed_tdata); 
Note: See TracChangeset for help on using the changeset viewer.