- Timestamp:
- Apr 11, 2007 6:30:31 PM (18 years ago)
- Location:
- pjproject/branches/pjproject-0.5-stable/pjsip
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/pjproject-0.5-stable/pjsip/include/pjsip/sip_transaction.h
r974 r1189 75 75 76 76 /** 77 * Transaction timeout timer policy, to control the UAC transaction timeout78 * scheduling (see #pjsip_tsx_set_uac_timeout()).79 */80 typedef enum pjsip_tsx_timeout_policy81 {82 PJSIP_TSX_IGNORE_100 = 1, /**< To make the UAC transaction NOT to cancel83 the timeout timer when 100 response is84 received.*/85 PJSIP_TSX_IGNORE_1xx = 3 /**< To make the UAC transaction NOT to cancel86 the timeout timer when any 1xx responses87 are received. */88 } pjsip_tsx_timeout_policy;89 90 91 /**92 77 * This structure describes SIP transaction object. The transaction object 93 78 * is used to handle both UAS and UAC transaction. … … 146 131 pj_timer_entry timeout_timer; /**< Timeout timer. */ 147 132 148 unsigned msec_timeout; /**< User set timeout. */149 pjsip_tsx_timeout_policy timeout_policy; /**< Timeout policy. */150 151 133 /** Module specific data. */ 152 134 void *mod_data[PJSIP_MAX_MODULE]; … … 249 231 const pjsip_tpselector *sel); 250 232 251 252 /**253 * Set the UAC absolute transaction timeout. Normally UAC transaction will254 * stop its timeout timer (timer B for INVITE and timer F for non-INVITE255 * transactions) after a provisional response is received.256 *257 * When this timer is set, the transaction's timer B and F will use this258 * value, and if the \a flag flag is set, the transaction will continue259 * the scheduling of the timeout timer even when provisional response has260 * been received.261 *262 * Note that this function MUST be called AFTER the transaction has been263 * created AND BEFORE any request is transmitted.264 *265 * @param tsx The client/UAC transaction.266 * @param msec_time The timeout value, in miliseconds. Currently this267 * value must be non-zero (value zero is reserved for268 * future use).269 * @param flag Option flags to control whether the transaction should270 * cancel the timeout timer on arrival of provisional271 * responses (which is yes according to RFC 3261).272 * The valid values are:273 * - PJSIP_TSX_IGNORE_100, to make the UAC transaction274 * NOT to cancel the timeout timer when 100 response275 * is received.276 * - PJSIP_TSX_IGNORE_1xx, to make the UAC transaction277 * NOT to cancel the timeout timer when any 1xx278 * responses are received.279 *280 * Note that regardless of the values in the \a flag281 * argument, the provisional response would still be282 * delivered to transaction user and it will still283 * affect the transaction state. The \a flag flag only284 * changes the behavior of the timeout timer of the285 * transaction.286 */287 PJ_DECL(pj_status_t) pjsip_tsx_set_uac_timeout(pjsip_transaction *tsx,288 unsigned msec_time,289 pjsip_tsx_timeout_policy flag);290 291 292 233 /** 293 234 * Call this function to manually feed a message to the transaction. -
pjproject/branches/pjproject-0.5-stable/pjsip/src/pjsip/sip_transaction.c
r1077 r1189 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 pj_assert(tsx->status_code < 200); 1798 1799 if (tsx->status_code >= 100) 1800 msec_time = PJSIP_T2_TIMEOUT; 1801 else 1802 msec_time = (1 << (tsx->retransmit_count)) * PJSIP_T1_TIMEOUT; 1813 1803 1814 1804 if (tsx->role == PJSIP_ROLE_UAC) { … … 1914 1904 1915 1905 /* 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. 1906 * timeout. 1918 1907 */ 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 } 1908 pjsip_endpt_schedule_timer( tsx->endpt, &tsx->timeout_timer, 1909 &timeout_timer_val); 1932 1910 1933 1911 /* Start Timer A (or timer E) for retransmission only if unreliable … … 2006 1984 return PJSIP_ENOTRESPONSEMSG; 2007 1985 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 } 1986 code = msg->line.status.code; 1987 1988 /* If the response is final, cancel both retransmission and timeout 1989 * timer. 1990 */ 1991 if (code >= 200) { 1992 if (tsx->retransmit_timer._timer_id != -1) { 1993 pjsip_endpt_cancel_timer(tsx->endpt, &tsx->retransmit_timer); 1994 tsx->retransmit_timer._timer_id = -1; 1995 } 1996 1997 if (tsx->timeout_timer._timer_id != -1) { 1998 pjsip_endpt_cancel_timer(tsx->endpt, &tsx->timeout_timer); 1999 tsx->timeout_timer._timer_id = -1; 2000 } 2001 2002 } else { 2003 /* Cancel retransmit timer (for non-INVITE transaction, the 2004 * retransmit timer will be rescheduled at T2. 2005 */ 2006 if (tsx->retransmit_timer._timer_id != -1) { 2007 pjsip_endpt_cancel_timer(tsx->endpt, &tsx->retransmit_timer); 2008 tsx->retransmit_timer._timer_id = -1; 2009 } 2010 2011 /* For provisional response, only cancel retransmit when this 2012 * is an INVITE transaction. For non-INVITE, section 17.1.2.1 2013 * of RFC 3261 says that: 2014 * - retransmit timer is set to T2 2015 * - timeout timer F is not deleted. 2016 */ 2017 if (tsx->method.id == PJSIP_INVITE_METHOD) { 2018 2019 /* Cancel timeout timer */ 2020 pjsip_endpt_cancel_timer(tsx->endpt, &tsx->timeout_timer); 2021 2022 } else { 2023 if (!tsx->is_reliable) { 2024 pjsip_endpt_schedule_timer(tsx->endpt, 2025 &tsx->retransmit_timer, 2026 &t2_timer_val); 2027 } 2028 } 2029 } 2030 2013 2031 tsx->transport_flag &= ~(TSX_HAS_PENDING_RESCHED); 2014 2032 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 2033 2029 2034 /* Discard retransmission message if it is not INVITE. … … 2368 2373 2369 2374 } else { 2370 tsx_set_status_code(tsx, PJSIP_SC_TSX_TIMEOUT, NULL); 2375 if (event->body.timer.entry == &tsx->retransmit_timer) { 2376 /* Retransmit message. */ 2377 pj_status_t status; 2378 2379 status = tsx_retransmit( tsx, 1 ); 2380 2381 return status; 2382 2383 } else { 2384 tsx_set_status_code(tsx, PJSIP_SC_TSX_TIMEOUT, NULL); 2385 } 2371 2386 } 2372 2387 -
pjproject/branches/pjproject-0.5-stable/pjsip/src/pjsip/sip_util_statefull.c
r974 r1189 95 95 PJ_ASSERT_RETURN(mod_stateful_util.id != -1, PJ_EINVALIDOP); 96 96 97 PJ_UNUSED_ARG(timeout); 97 98 98 99 status = pjsip_tsx_create_uac(&mod_stateful_util, tdata, &tsx); … … 105 106 tsx_data->token = token; 106 107 tsx_data->cb = cb; 107 108 if (timeout >= 0) {109 status = pjsip_tsx_set_uac_timeout(tsx, timeout, PJSIP_TSX_IGNORE_1xx);110 pj_assert(status == PJ_SUCCESS);111 }112 108 113 109 tsx->mod_data[mod_stateful_util.id] = tsx_data;
Note: See TracChangeset
for help on using the changeset viewer.