Changeset 942 for pjproject/trunk/pjsip/src/pjsip/sip_util_statefull.c
- Timestamp:
- Feb 13, 2007 2:52:37 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip/sip_util_statefull.c
r932 r942 30 30 struct tsx_data 31 31 { 32 pj_time_val delay;33 pj_timer_entry timeout_timer;34 35 32 void *token; 36 33 void (*cb)(void*, pjsip_event*); … … 72 69 return; 73 70 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 80 71 /* Call the callback, if any, and prevent the callback to be called again 81 72 * by clearing the transaction's module_data. … … 86 77 (*tsx_data->cb)(tsx_data->token, event); 87 78 } 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);111 79 } 112 80 … … 134 102 } 135 103 136 tsx_data = pj_pool_ zalloc(tsx->pool, sizeof(struct tsx_data));104 tsx_data = pj_pool_alloc(tsx->pool, sizeof(struct tsx_data)); 137 105 tsx_data->token = token; 138 106 tsx_data->cb = cb; 139 107 140 108 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); 156 111 } 157 112 … … 159 114 160 115 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) 166 117 pjsip_tx_data_dec_ref(tdata); 167 }168 118 169 119 return status;
Note: See TracChangeset
for help on using the changeset viewer.