Ignore:
Timestamp:
Apr 11, 2007 7:48:42 PM (17 years ago)
Author:
bennylp
Message:

Applying ticket #220 to Symbian branch: Bug in retransmission of non-INVITE SIP requests in UAC transaction (thanks Martin Peterzon)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/symbian/pjsip/src/pjsip/sip_transaction.c

    r789 r1192  
    126126static const pj_time_val t1_timer_val = { PJSIP_T1_TIMEOUT/1000,  
    127127                                          PJSIP_T1_TIMEOUT%1000 }; 
     128static const pj_time_val t2_timer_val = { PJSIP_T2_TIMEOUT/1000,  
     129                                          PJSIP_T2_TIMEOUT%1000 }; 
    128130static const pj_time_val t4_timer_val = { PJSIP_T4_TIMEOUT/1000,  
    129131                                          PJSIP_T4_TIMEOUT%1000 }; 
     
    17041706    pj_assert((tsx->transport_flag & TSX_HAS_PENDING_TRANSPORT) == 0); 
    17051707 
    1706     msec_time = (1 << (tsx->retransmit_count)) * PJSIP_T1_TIMEOUT; 
     1708    pj_assert(tsx->status_code < 200); 
     1709 
     1710    if (tsx->status_code >= 100) 
     1711        msec_time = PJSIP_T2_TIMEOUT; 
     1712    else 
     1713        msec_time = (1 << (tsx->retransmit_count)) * PJSIP_T1_TIMEOUT; 
    17071714 
    17081715    if (tsx->role == PJSIP_ROLE_UAC) { 
     
    18791886    } else if (event->type == PJSIP_EVENT_RX_MSG) { 
    18801887        pjsip_msg *msg; 
    1881         //int code; 
     1888        int code; 
    18821889 
    18831890        /* Get message instance */ 
    18841891        msg = event->body.rx_msg.rdata->msg_info.msg; 
    18851892 
    1886         /* Better be a response message. */ 
    1887         if (msg->type != PJSIP_RESPONSE_MSG) 
    1888             return PJSIP_ENOTRESPONSEMSG; 
    1889  
    1890         /* Cancel retransmission timer A. */ 
    1891         if (tsx->retransmit_timer._timer_id != -1) { 
    1892             pjsip_endpt_cancel_timer(tsx->endpt, &tsx->retransmit_timer); 
    1893             tsx->retransmit_timer._timer_id = -1; 
    1894         } 
     1893        code = msg->line.status.code; 
     1894 
     1895        /* If the response is final, cancel both retransmission and timeout 
     1896         * timer. 
     1897         */ 
     1898        if (code >= 200) { 
     1899            if (tsx->retransmit_timer._timer_id != -1) { 
     1900                pjsip_endpt_cancel_timer(tsx->endpt, &tsx->retransmit_timer); 
     1901                tsx->retransmit_timer._timer_id = -1; 
     1902            } 
     1903 
     1904            if (tsx->timeout_timer._timer_id != -1) { 
     1905                pjsip_endpt_cancel_timer(tsx->endpt, &tsx->timeout_timer); 
     1906                tsx->timeout_timer._timer_id = -1; 
     1907            } 
     1908 
     1909        } else { 
     1910            /* Cancel retransmit timer (for non-INVITE transaction, the 
     1911             * retransmit timer will be rescheduled at T2. 
     1912             */ 
     1913            if (tsx->retransmit_timer._timer_id != -1) { 
     1914                pjsip_endpt_cancel_timer(tsx->endpt, &tsx->retransmit_timer); 
     1915                tsx->retransmit_timer._timer_id = -1; 
     1916            } 
     1917 
     1918            /* For provisional response, only cancel retransmit when this 
     1919             * is an INVITE transaction. For non-INVITE, section 17.1.2.1 
     1920             * of RFC 3261 says that: 
     1921             *  - retransmit timer is set to T2 
     1922             *  - timeout timer F is not deleted. 
     1923             */ 
     1924            if (tsx->method.id == PJSIP_INVITE_METHOD) { 
     1925 
     1926                /* Cancel timeout timer */ 
     1927                pjsip_endpt_cancel_timer(tsx->endpt, &tsx->timeout_timer); 
     1928 
     1929            } else { 
     1930                if (!tsx->is_reliable) { 
     1931                    pjsip_endpt_schedule_timer(tsx->endpt,  
     1932                                               &tsx->retransmit_timer, 
     1933                                               &t2_timer_val); 
     1934                } 
     1935            } 
     1936        } 
     1937  
    18951938        tsx->transport_flag &= ~(TSX_HAS_PENDING_RESCHED); 
    1896  
    1897  
    1898         /* Cancel timer B (transaction timeout) */ 
    1899         pjsip_endpt_cancel_timer(tsx->endpt, &tsx->timeout_timer); 
    19001939 
    19011940        /* Discard retransmission message if it is not INVITE. 
     
    22222261        tsx->status_code = msg->line.status.code; 
    22232262    } else { 
    2224         tsx->status_code = PJSIP_SC_TSX_TIMEOUT; 
     2263        if (event->body.timer.entry == &tsx->retransmit_timer) { 
     2264            /* Retransmit message. */ 
     2265            pj_status_t status; 
     2266 
     2267            status = tsx_retransmit( tsx, 1 ); 
     2268             
     2269            return status; 
     2270 
     2271        } else { 
     2272            tsx->status_code = PJSIP_SC_TSX_TIMEOUT; 
     2273        } 
    22252274    } 
    22262275 
     
    22662315        } 
    22672316 
     2317    } else if (event->type == PJSIP_EVENT_TIMER && 
     2318               event->body.timer.entry == &tsx->timeout_timer) { 
     2319 
     2320        /* Inform TU. */ 
     2321        tsx_set_state( tsx, PJSIP_TSX_STATE_TERMINATED,  
     2322                       PJSIP_EVENT_TIMER, &tsx->timeout_timer); 
     2323 
     2324 
    22682325    } else if (tsx->status_code >= 300 && tsx->status_code <= 699) { 
    22692326 
Note: See TracChangeset for help on using the changeset viewer.