int add_phony_uac( struct cell *t) { str dummy_buffer = str_init("DUMMY"); unsigned short branch; utime_t timer; branch=t->nr_of_outgoings; if (branch==MAX_BRANCHES) { LM_ERR("maximum number of branches exceeded\n"); return E_CFG; } /* check existing buffer -- rewriting should never occur */ if (t->uac[branch].request.buffer.s) { LM_CRIT("buffer rewrite attempt\n"); ser_error=E_BUG; return E_BUG; } /* we attach a dummy buffer just to pass all the "tests" for a * valid branch */ t->uac[branch].request.buffer.s = (char*)shm_malloc(dummy_buffer.len); if (t->uac[branch].request.buffer.s==NULL) { LM_ERR("failed to alloc dummy buffer for phony branch\n"); /* there is nothing to reset on the branch */ return E_OUT_OF_MEM; } memcpy( t->uac[branch].request.buffer.s, dummy_buffer.s, dummy_buffer.len); t->uac[branch].request.buffer.len = dummy_buffer.len; t->uac[branch].request.my_T = t; t->uac[branch].request.branch = branch; t->uac[branch].flags = T_UAC_IS_PHONY; /* in invalid proto will prevent adding this retransmission buffer * to the retransmission timer (there is nothing to retransmit here :P */ t->uac[branch].request.dst.proto = PROTO_NONE; t->nr_of_outgoings++; /* we set here only FR (final response) timer, to be sure this branch * comes to an end - as timeout value we use exactly the same value the * transaction has set as FR_INV_TIMEOUT */ if (is_timeout_set(t->fr_inv_timeout)) { timer = t->fr_inv_timeout; set_1timer(&t->uac[branch].request.fr_timer, FR_INV_TIMER_LIST,&timer); } else { set_1timer(&t->uac[branch].request.fr_timer, FR_INV_TIMER_LIST, NULL); } set_kr(REQ_FWDED); return 0; }
void put_on_wait( struct cell *Trans ) { #ifdef EXTRA_DEBUG LM_DBG("put on WAIT \n"); #endif /* we put the transaction on wait timer; we do it only once in transaction's timelife because putting it multiple-times might result in a second instance of a wait timer to be set after the first one fired; on expiration of the second instance, the transaction would be re-deleted PROCESS1 PROCESS2 TIMER PROCESS 0. 200/INVITE rx; put_on_wait 1. 200/INVITE rx; 2. WAIT fires; transaction about to be deleted 3. avoid putting on WAIT again 4. WAIT timer executed, transaction deleted */ set_1timer( &Trans->wait_tl, WT_TIMER_LIST, 0 ); }
inline void _set_fr_retr( struct retr_buf *rb, int retr ) { utime_t timer; if (retr && !rb->retr_timer.deleted) { rb->retr_list=RT_T1_TO_1; set_timer( &rb->retr_timer, RT_T1_TO_1, NULL ); } if (!rb->my_T || !is_timeout_set(rb->my_T->fr_timeout)) set_1timer(&rb->fr_timer, FR_TIMER_LIST, NULL); else { timer = rb->my_T->fr_timeout; set_1timer(&rb->fr_timer, FR_TIMER_LIST, &timer); } }