- Timestamp:
- Apr 22, 2007 12:48:30 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/split-3rd-party/pjsip/src/pjsip/sip_transaction.c
r1079 r1210 133 133 static const pj_time_val t1_timer_val = { PJSIP_T1_TIMEOUT/1000, 134 134 PJSIP_T1_TIMEOUT%1000 }; 135 static const pj_time_val t2_timer_val = { PJSIP_T2_TIMEOUT/1000, 136 PJSIP_T2_TIMEOUT%1000 }; 135 137 static const pj_time_val t4_timer_val = { PJSIP_T4_TIMEOUT/1000, 136 138 PJSIP_T4_TIMEOUT%1000 }; … … 1397 1399 1398 1400 /* 1399 * Set the UAC absolute transaction timeout.1400 */1401 PJ_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 /*1416 1401 * Set transaction status code and reason. 1417 1402 */ … … 1810 1795 pj_assert((tsx->transport_flag & TSX_HAS_PENDING_TRANSPORT) == 0); 1811 1796 1812 msec_time = (1 << (tsx->retransmit_count)) * PJSIP_T1_TIMEOUT; 1797 if (tsx->role==PJSIP_ROLE_UAC && tsx->status_code >= 100) 1798 msec_time = PJSIP_T2_TIMEOUT; 1799 else 1800 msec_time = (1 << (tsx->retransmit_count)) * PJSIP_T1_TIMEOUT; 1813 1801 1814 1802 if (tsx->role == PJSIP_ROLE_UAC) { 1803 pj_assert(tsx->status_code < 200); 1815 1804 /* Retransmission for non-INVITE transaction caps-off at T2 */ 1816 1805 if (msec_time>PJSIP_T2_TIMEOUT && tsx->method.id!=PJSIP_INVITE_METHOD) … … 1914 1903 1915 1904 /* Start Timer B (or called timer F for non-INVITE) for transaction 1916 * timeout. If user has configured the timeout value with 1917 * pjsip_tsx_set_uac_timeout(), use the timeout value there. 1905 * timeout. 1918 1906 */ 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 } 1907 pjsip_endpt_schedule_timer( tsx->endpt, &tsx->timeout_timer, 1908 &timeout_timer_val); 1932 1909 1933 1910 /* Start Timer A (or timer E) for retransmission only if unreliable … … 2006 1983 return PJSIP_ENOTRESPONSEMSG; 2007 1984 2008 /* Cancel retransmission timer A. */ 2009 if (tsx->retransmit_timer._timer_id != -1) { 2010 pjsip_endpt_cancel_timer(tsx->endpt, &tsx->retransmit_timer); 2011 tsx->retransmit_timer._timer_id = -1; 2012 } 1985 code = msg->line.status.code; 1986 1987 /* If the response is final, cancel both retransmission and timeout 1988 * timer. 1989 */ 1990 if (code >= 200) { 1991 if (tsx->retransmit_timer._timer_id != -1) { 1992 pjsip_endpt_cancel_timer(tsx->endpt, &tsx->retransmit_timer); 1993 tsx->retransmit_timer._timer_id = -1; 1994 } 1995 1996 if (tsx->timeout_timer._timer_id != -1) { 1997 pjsip_endpt_cancel_timer(tsx->endpt, &tsx->timeout_timer); 1998 tsx->timeout_timer._timer_id = -1; 1999 } 2000 2001 } else { 2002 /* Cancel retransmit timer (for non-INVITE transaction, the 2003 * retransmit timer will be rescheduled at T2. 2004 */ 2005 if (tsx->retransmit_timer._timer_id != -1) { 2006 pjsip_endpt_cancel_timer(tsx->endpt, &tsx->retransmit_timer); 2007 tsx->retransmit_timer._timer_id = -1; 2008 } 2009 2010 /* For provisional response, only cancel retransmit when this 2011 * is an INVITE transaction. For non-INVITE, section 17.1.2.1 2012 * of RFC 3261 says that: 2013 * - retransmit timer is set to T2 2014 * - timeout timer F is not deleted. 2015 */ 2016 if (tsx->method.id == PJSIP_INVITE_METHOD) { 2017 2018 /* Cancel timeout timer */ 2019 pjsip_endpt_cancel_timer(tsx->endpt, &tsx->timeout_timer); 2020 2021 } else { 2022 if (!tsx->is_reliable) { 2023 pjsip_endpt_schedule_timer(tsx->endpt, 2024 &tsx->retransmit_timer, 2025 &t2_timer_val); 2026 } 2027 } 2028 } 2029 2013 2030 tsx->transport_flag &= ~(TSX_HAS_PENDING_RESCHED); 2014 2031 2015 2016 /* Cancel timer B (transaction timeout) but look at the timeout policy2017 * 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 }2028 2032 2029 2033 /* Discard retransmission message if it is not INVITE. … … 2368 2372 2369 2373 } else { 2370 tsx_set_status_code(tsx, PJSIP_SC_TSX_TIMEOUT, NULL); 2374 if (event->body.timer.entry == &tsx->retransmit_timer) { 2375 /* Retransmit message. */ 2376 pj_status_t status; 2377 2378 status = tsx_retransmit( tsx, 1 ); 2379 2380 return status; 2381 2382 } else { 2383 tsx_set_status_code(tsx, PJSIP_SC_TSX_TIMEOUT, NULL); 2384 } 2371 2385 } 2372 2386 … … 2407 2421 &timeout); 2408 2422 2423 /* Cancel retransmission timer */ 2424 if (tsx->retransmit_timer._timer_id != -1) { 2425 pjsip_endpt_cancel_timer(tsx->endpt, &tsx->retransmit_timer); 2426 tsx->retransmit_timer._timer_id = -1; 2427 } 2428 2409 2429 /* Move state to Completed, inform TU. */ 2410 2430 tsx_set_state( tsx, PJSIP_TSX_STATE_COMPLETED,
Note: See TracChangeset
for help on using the changeset viewer.