Changeset 1988 for pjproject/trunk/pjnath/src/pjnath/stun_transaction.c
- Timestamp:
- Jun 6, 2008 2:47:10 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjnath/src/pjnath/stun_transaction.c
r1410 r1988 32 32 { 33 33 char obj_name[PJ_MAX_OBJ_NAME]; 34 pj_stun_config *cfg;35 34 pj_stun_tsx_cb cb; 36 35 void *user_data; … … 39 38 40 39 pj_bool_t require_retransmit; 40 unsigned rto_msec; 41 41 pj_timer_entry retransmit_timer; 42 42 unsigned transmit_count; 43 43 pj_time_val retransmit_time; 44 pj_timer_heap_t *timer_heap; 44 45 45 46 pj_timer_entry destroy_timer; … … 71 72 72 73 tsx = PJ_POOL_ZALLOC_T(pool, pj_stun_client_tsx); 73 tsx->cfg = cfg; 74 tsx->rto_msec = cfg->rto_msec; 75 tsx->timer_heap = cfg->timer_heap; 74 76 pj_memcpy(&tsx->cb, cb, sizeof(*cb)); 75 77 … … 100 102 /* Cancel previously registered timer */ 101 103 if (tsx->destroy_timer.id != 0) { 102 pj_timer_heap_cancel(tsx-> cfg->timer_heap, &tsx->destroy_timer);104 pj_timer_heap_cancel(tsx->timer_heap, &tsx->destroy_timer); 103 105 tsx->destroy_timer.id = 0; 104 106 } … … 106 108 /* Stop retransmission, just in case */ 107 109 if (tsx->retransmit_timer.id != 0) { 108 pj_timer_heap_cancel(tsx-> cfg->timer_heap, &tsx->retransmit_timer);109 tsx->retransmit_timer.id = 0; 110 } 111 112 status = pj_timer_heap_schedule(tsx-> cfg->timer_heap,110 pj_timer_heap_cancel(tsx->timer_heap, &tsx->retransmit_timer); 111 tsx->retransmit_timer.id = 0; 112 } 113 114 status = pj_timer_heap_schedule(tsx->timer_heap, 113 115 &tsx->destroy_timer, delay); 114 116 if (status != PJ_SUCCESS) … … 116 118 117 119 tsx->destroy_timer.id = TIMER_ACTIVE; 120 tsx->cb.on_complete = NULL; 118 121 119 122 return PJ_SUCCESS; … … 129 132 130 133 if (tsx->retransmit_timer.id != 0) { 131 pj_timer_heap_cancel(tsx-> cfg->timer_heap, &tsx->retransmit_timer);134 pj_timer_heap_cancel(tsx->timer_heap, &tsx->retransmit_timer); 132 135 tsx->retransmit_timer.id = 0; 133 136 } 134 137 if (tsx->destroy_timer.id != 0) { 135 pj_timer_heap_cancel(tsx-> cfg->timer_heap, &tsx->destroy_timer);138 pj_timer_heap_cancel(tsx->timer_heap, &tsx->destroy_timer); 136 139 tsx->destroy_timer.id = 0; 137 140 } … … 187 190 if (tsx->transmit_count == 0) { 188 191 tsx->retransmit_time.sec = 0; 189 tsx->retransmit_time.msec = tsx-> cfg->rto_msec;192 tsx->retransmit_time.msec = tsx->rto_msec; 190 193 191 194 } else if (tsx->transmit_count < PJ_STUN_MAX_TRANSMIT_COUNT-1) { … … 206 209 * cancel transmission). 207 210 */; 208 status = pj_timer_heap_schedule(tsx-> cfg->timer_heap,211 status = pj_timer_heap_schedule(tsx->timer_heap, 209 212 &tsx->retransmit_timer, 210 213 &tsx->retransmit_time); … … 224 227 /* Send message */ 225 228 status = tsx->cb.on_send_msg(tsx, tsx->last_pkt, tsx->last_pkt_size); 226 if (status != PJ_SUCCESS) { 229 230 if (status == PJNATH_ESTUNDESTROYED) { 231 /* We've been destroyed, don't access the object. */ 232 } else if (status != PJ_SUCCESS) { 227 233 if (tsx->retransmit_timer.id != 0) { 228 pj_timer_heap_cancel(tsx-> cfg->timer_heap,234 pj_timer_heap_cancel(tsx->timer_heap, 229 235 &tsx->retransmit_timer); 230 236 tsx->retransmit_timer.id = 0; … … 280 286 } 281 287 } 288 /* We might have been destroyed, don't try to access the object */ 282 289 return; 283 290 } … … 285 292 tsx->retransmit_timer.id = 0; 286 293 status = tsx_transmit_msg(tsx); 287 if (status != PJ_SUCCESS) { 294 if (status == PJNATH_ESTUNDESTROYED) { 295 /* We've been destroyed, don't try to access the object */ 296 } else if (status != PJ_SUCCESS) { 288 297 tsx->retransmit_timer.id = 0; 289 298 if (!tsx->complete) { … … 293 302 } 294 303 } 304 /* We might have been destroyed, don't try to access the object */ 295 305 } 296 306 } … … 306 316 307 317 if (tsx->retransmit_timer.id != 0) { 308 pj_timer_heap_cancel(tsx-> cfg->timer_heap, &tsx->retransmit_timer);318 pj_timer_heap_cancel(tsx->timer_heap, &tsx->retransmit_timer); 309 319 tsx->retransmit_timer.id = 0; 310 320 } … … 352 362 */ 353 363 if (tsx->retransmit_timer.id) { 354 pj_timer_heap_cancel(tsx-> cfg->timer_heap, &tsx->retransmit_timer);364 pj_timer_heap_cancel(tsx->timer_heap, &tsx->retransmit_timer); 355 365 tsx->retransmit_timer.id = 0; 356 366 } … … 385 395 tsx->cb.on_complete(tsx, status, msg, src_addr, src_addr_len); 386 396 } 397 /* We might have been destroyed, don't try to access the object */ 387 398 } 388 399
Note: See TracChangeset
for help on using the changeset viewer.