nta_error_magic_t *sa_error_magic;
nta_error_tport_f *sa_error_tport;
- su_time_t sa_now; /**< Timestamp in microsecond resolution. */
uint32_t sa_next; /**< Timestamp for next agent_timer. */
- uint32_t sa_millisec; /**< Timestamp in milliseconds. */
msg_mclass_t const *sa_mclass;
uint32_t sa_flags; /**< SIP message flags */
agent->sa_next = 0;
- agent->sa_now = stamp;
- agent->sa_millisec = now;
agent->sa_in_timer = 1;
+
_nta_outgoing_timer(agent);
_nta_incoming_timer(agent);
- /* agent->sa_now is used only if sa_millisec != 0 */
- agent->sa_millisec = 0;
agent->sa_in_timer = 0;
/* Calculate next timeout */
if (offset == 0)
return 0;
- if (agent->sa_millisec) /* Avoid expensive call to su_now() */
- now = agent->sa_now, ms = agent->sa_millisec;
- else
- now = su_now(), ms = su_time_ms(now);
+ now = su_now();
+ ms = su_time_ms(now);
- next = ms + offset; if (next == 0) next = 1;
+ next = ms + offset;
+
+ if (next == 0) next = 1;
if (agent->sa_in_timer) /* Currently executing timer */
return next;
static
su_time_t agent_now(nta_agent_t const *agent)
{
- if (agent && agent->sa_millisec != 0)
- return agent->sa_now;
- else
return su_now();
}
{
sip_t *sip = sip_object(msg);
- agent->sa_millisec = su_time_ms(agent->sa_now = now);
-
if (sip && sip->sip_request) {
agent_recv_request(agent, msg, sip, tport);
}
else {
agent_recv_garbage(agent, msg, tport);
}
-
- agent->sa_millisec = 0;
}
/** @internal Handle incoming requests. */
static void
_nta_incoming_timer(nta_agent_t *sa)
{
- uint32_t now = sa->sa_millisec;
+ uint32_t now = su_time_ms(su_now());
nta_incoming_t *irq, *irq_next;
size_t retransmitted = 0, timeout = 0, terminated = 0, destroyed = 0;
size_t unconfirmed =
/* Handle retry queue */
while ((irq = sa->sa_in.re_list)) {
+
+ now = su_time_ms(su_now());
+
if ((int32_t)(irq->irq_retry - now) > 0)
break;
if (retransmitted >= timer_max_retransmit)
}
while ((irq = sa->sa_in.final_failed->q_head)) {
+
+
incoming_remove(irq);
irq->irq_final_failed = 0;
assert(irq->irq_status < 200);
assert(irq->irq_timeout);
+ now = su_time_ms(su_now());
+
if ((int32_t)(irq->irq_timeout - now) > 0)
break;
if (timeout >= timer_max_timeout)
assert(irq->irq_timeout);
assert(irq->irq_method == sip_method_invite);
+ now = su_time_ms(su_now());
+
if ((int32_t)(irq->irq_timeout - now) > 0 ||
timeout >= timer_max_timeout ||
terminated >= timer_max_terminate)
assert(irq->irq_status >= 200);
assert(irq->irq_method == sip_method_invite);
+ now = su_time_ms(su_now());
+
if ((int32_t)(irq->irq_timeout - now) > 0 ||
terminated >= timer_max_terminate)
break;
assert(irq->irq_timeout);
assert(irq->irq_method != sip_method_invite);
+ now = su_time_ms(su_now());
+
if ((int32_t)(irq->irq_timeout - now) > 0 ||
terminated >= timer_max_terminate)
break;
}
for (irq = sa->sa_in.terminated->q_head; irq; irq = irq_next) {
+
irq_next = irq->irq_next;
if (irq->irq_destroyed)
incoming_free_queue(rq, irq);
static void
_nta_outgoing_timer(nta_agent_t *sa)
{
- uint32_t now = sa->sa_millisec;
+ uint32_t now = su_time_ms(su_now());
nta_outgoing_t *orq;
outgoing_queue_t rq[1];
size_t retransmitted = 0, terminated = 0, timeout = 0, destroyed;
outgoing_queue_init(sa->sa_out.free = rq, 0);
while ((orq = sa->sa_out.re_list)) {
+
+ now = su_time_ms(su_now());
+
if ((int32_t)(orq->orq_retry - now) > 0)
break;
if (retransmitted >= timer_max_retransmit)