Ignore:
Timestamp:
Feb 13, 2007 2:52:37 AM (17 years ago)
Author:
bennylp
Message:

Implement ticket #99: a more generic mechanism to implement UAC transaction timeout after provisional response is received

File:
1 edited

Legend:

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

    r882 r942  
    13971397 
    13981398/* 
     1399 * Set the UAC absolute transaction timeout. 
     1400 */ 
     1401PJ_DEF(pj_status_t) pjsip_tsx_set_uac_timeout(pjsip_transaction *tsx, 
     1402                                              unsigned msec_time, 
     1403                                              pjsip_tsx_timeout_policy policy) 
     1404{ 
     1405    PJ_ASSERT_RETURN(tsx && tsx->role==PJSIP_ROLE_UAC && 
     1406                     tsx->state==PJSIP_TSX_STATE_NULL, PJ_EINVALIDOP); 
     1407 
     1408    tsx->msec_timeout = msec_time; 
     1409    tsx->timeout_policy = policy; 
     1410 
     1411    return PJ_SUCCESS; 
     1412} 
     1413 
     1414 
     1415/* 
    13991416 * Set transaction status code and reason. 
    14001417 */ 
     
    18971914 
    18981915        /* Start Timer B (or called timer F for non-INVITE) for transaction  
    1899          * timeout. 
     1916         * timeout. If user has configured the timeout value with  
     1917         * pjsip_tsx_set_uac_timeout(), use the timeout value there. 
    19001918         */ 
    1901         pjsip_endpt_schedule_timer( tsx->endpt, &tsx->timeout_timer,  
    1902                                     &timeout_timer_val); 
     1919        if (tsx->msec_timeout > 0) { 
     1920            pj_time_val timeout; 
     1921 
     1922            timeout.sec = tsx->msec_timeout / 1000; 
     1923            timeout.msec = tsx->msec_timeout % 1000; 
     1924 
     1925            pjsip_endpt_schedule_timer( tsx->endpt, &tsx->timeout_timer,  
     1926                                        &timeout); 
     1927 
     1928        } else { 
     1929            pjsip_endpt_schedule_timer( tsx->endpt, &tsx->timeout_timer,  
     1930                                        &timeout_timer_val); 
     1931        } 
    19031932 
    19041933        /* Start Timer A (or timer E) for retransmission only if unreliable  
     
    19681997    } else if (event->type == PJSIP_EVENT_RX_MSG) { 
    19691998        pjsip_msg *msg; 
    1970         //int code; 
     1999        int code; 
    19712000 
    19722001        /* Get message instance */ 
     
    19852014 
    19862015 
    1987         /* Cancel timer B (transaction timeout) */ 
    1988         pjsip_endpt_cancel_timer(tsx->endpt, &tsx->timeout_timer); 
     2016        /* Cancel timer B (transaction timeout) but look at the timeout policy 
     2017         * as set by pjsip_tsx_set_uac_timeout(). 
     2018         */ 
     2019        code = msg->line.status.code; 
     2020        if ((code==100 && tsx->timeout_policy==PJSIP_TSX_IGNORE_100) || 
     2021            (code<200 && tsx->timeout_policy==PJSIP_TSX_IGNORE_1xx)) 
     2022        { 
     2023            /* Don't cancel the timeout timer */ 
     2024        } 
     2025        else { 
     2026            pjsip_endpt_cancel_timer(tsx->endpt, &tsx->timeout_timer); 
     2027        } 
    19892028 
    19902029        /* Discard retransmission message if it is not INVITE. 
     
    23732412        } 
    23742413 
     2414    } else if (event->type == PJSIP_EVENT_TIMER && 
     2415               event->body.timer.entry == &tsx->timeout_timer) { 
     2416 
     2417        /* Inform TU. */ 
     2418        tsx_set_state( tsx, PJSIP_TSX_STATE_TERMINATED,  
     2419                       PJSIP_EVENT_TIMER, &tsx->timeout_timer); 
     2420 
     2421 
    23752422    } else if (tsx->status_code >= 300 && tsx->status_code <= 699) { 
    23762423 
Note: See TracChangeset for help on using the changeset viewer.