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_util_statefull.c

    r932 r942  
    3030struct tsx_data 
    3131{ 
    32     pj_time_val     delay; 
    33     pj_timer_entry  timeout_timer; 
    34  
    3532    void *token; 
    3633    void (*cb)(void*, pjsip_event*); 
     
    7269        return; 
    7370 
    74     /* Cancel timer if any */ 
    75     if (tsx_data->timeout_timer.id != 0) { 
    76         tsx_data->timeout_timer.id = 0; 
    77         pjsip_endpt_cancel_timer(tsx->endpt, &tsx_data->timeout_timer); 
    78     } 
    79  
    8071    /* Call the callback, if any, and prevent the callback to be called again 
    8172     * by clearing the transaction's module_data. 
     
    8677        (*tsx_data->cb)(tsx_data->token, event); 
    8778    } 
    88 } 
    89  
    90  
    91 static void mod_util_on_timeout(pj_timer_heap_t *th, pj_timer_entry *te) 
    92 { 
    93     pjsip_transaction *tsx = (pjsip_transaction*) te->user_data; 
    94     struct tsx_data *tsx_data; 
    95  
    96     PJ_UNUSED_ARG(th); 
    97  
    98     tsx_data = tsx->mod_data[mod_stateful_util.id]; 
    99     if (tsx_data == NULL) { 
    100         pj_assert(!"Shouldn't happen"); 
    101         return; 
    102     } 
    103  
    104     tsx_data->timeout_timer.id = 0; 
    105  
    106     PJ_LOG(4,(tsx->obj_name, "Transaction timed out by user timer (%d.%d sec)", 
    107               (int)tsx_data->delay.sec, (int)tsx_data->delay.msec)); 
    108  
    109     /* Terminate the transaction. This will call mod_util_on_tsx_state() */ 
    110     pjsip_tsx_terminate(tsx, PJSIP_SC_TSX_TIMEOUT); 
    11179} 
    11280 
     
    134102    } 
    135103 
    136     tsx_data = pj_pool_zalloc(tsx->pool, sizeof(struct tsx_data)); 
     104    tsx_data = pj_pool_alloc(tsx->pool, sizeof(struct tsx_data)); 
    137105    tsx_data->token = token; 
    138106    tsx_data->cb = cb; 
    139107 
    140108    if (timeout >= 0) { 
    141         tsx_data->delay.sec = 0; 
    142         tsx_data->delay.msec = timeout; 
    143         pj_time_val_normalize(&tsx_data->delay); 
    144  
    145         tsx_data->timeout_timer.id = PJ_TRUE; 
    146         tsx_data->timeout_timer.user_data = tsx; 
    147         tsx_data->timeout_timer.cb = &mod_util_on_timeout; 
    148          
    149         status = pjsip_endpt_schedule_timer(endpt, &tsx_data->timeout_timer,  
    150                                             &tsx_data->delay); 
    151         if (status != PJ_SUCCESS) { 
    152             pjsip_tsx_terminate(tsx, PJSIP_SC_INTERNAL_SERVER_ERROR); 
    153             pjsip_tx_data_dec_ref(tdata); 
    154             return status; 
    155         } 
     109        status = pjsip_tsx_set_uac_timeout(tsx, timeout, PJSIP_TSX_IGNORE_1xx); 
     110        pj_assert(status == PJ_SUCCESS); 
    156111    } 
    157112 
     
    159114 
    160115    status = pjsip_tsx_send_msg(tsx, NULL); 
    161     if (status != PJ_SUCCESS) { 
    162         if (tsx_data->timeout_timer.id != 0) { 
    163             pjsip_endpt_cancel_timer(endpt, &tsx_data->timeout_timer); 
    164             tsx_data->timeout_timer.id = PJ_FALSE; 
    165         } 
     116    if (status != PJ_SUCCESS) 
    166117        pjsip_tx_data_dec_ref(tdata); 
    167     } 
    168118 
    169119    return status; 
Note: See TracChangeset for help on using the changeset viewer.