* already a bit complex.
*/
rad_assert(u->timer.retry == &c->inst->parent->retry[u->code]);
- rcode = rr_track_retry(u, &u->timer, c->thread->el, status_check_timeout, u, now);
+ rcode = rr_track_retry(&u->timer, now);
if (rcode < 0) {
/*
* Failed inserting event... the request is done.
return;
}
+ if (fr_event_timer_insert(u, c->thread->el, &u->timer.ev, &u->timer.next, status_check_timeout, u) < 0) {
+ RDEBUG("Failed inserting status check timer for connection %s", c->name);
+ talloc_free(c);
+ return;
+ }
+
/*
* Link it into the connection queue for retransmission.
*/
*/
if (u->rr) RDEBUG("Retransmitting ID %d on connection %s", u->rr->id, c->name);
- rcode = rr_track_retry(u, &u->timer, el, response_timeout, u, now);
+ rcode = rr_track_retry(&u->timer, now);
if (rcode < 0) {
if (c) {
REDEBUG("Failing proxied request ID %d due to error trying to proxy on connection %s",
return;
}
+ if (fr_event_timer_insert(u, el, &u->timer.ev, &u->timer.next, response_timeout, u) < 0) {
+ RDEBUG("Failed inserting status check timer for connection %s", c->name);
+ mod_finished_request(c, u);
+ return;
+ }
+
/*
* If we can retransmit it, do so. Otherwise, it will
* get retransmitted when we get around to polling
if (!c->inst->parent->synchronous) {
rad_assert(u->timer.retry == &c->inst->parent->retry[u->code]);
- if (rr_track_start(u, &u->timer, c->thread->el, response_timeout, u) < 0) {
+ if (rr_track_start(&u->timer) < 0) {
+ RDEBUG("Failed starting retransmit tracking");
+ return -1;
+ }
+
+ if (fr_event_timer_insert(u, c->thread->el, &u->timer.ev, &u->timer.next,
+ response_timeout, u) < 0) {
RDEBUG("Failed starting retransmit tracking");
return -1;
}
} else if (u->timer.count == 0) {
rad_assert(u->timer.retry == &c->inst->parent->retry[u->code]);
- if (rr_track_start(u, &u->timer, c->thread->el, status_check_timeout, u) < 0) {
+ if (rr_track_start(&u->timer) < 0) {
RDEBUG("Failed starting retransmit tracking");
return -1;
}
+ if (fr_event_timer_insert(u, c->thread->el, &u->timer.ev, &u->timer.next,
+ status_check_timeout, u) < 0) {
+ RDEBUG("Failed starting retransmit tracking");
+ return -1;
+ }
+
RDEBUG("Sending %s status check. Expecting response within %d.%06ds",
fr_packet_codes[u->code],
u->timer.rt / USEC, u->timer.rt % USEC);
id->use_authenticator = flag;
}
-int rr_track_retry(TALLOC_CTX *ctx, rlm_radius_retransmit_t *timer, fr_event_list_t *el,
- fr_event_cb_t callback, void *uctx,
- struct timeval *now)
+int rr_track_retry(rlm_radius_retransmit_t *timer, struct timeval *now)
{
uint32_t delay, frac;
- struct timeval next;
/*
* Get when we SHOULD have woken up, which might not be
* the same as 'now'.
*/
- next = timer->start;
- next.tv_usec += timer->rt;
+ timer->next = timer->start;
+ timer->next.tv_usec += timer->rt;
/*
* Increment retransmission counter
/*
* Get the next delay time.
*/
- next.tv_usec += timer->rt;
- next.tv_sec += (next.tv_usec / USEC);
- next.tv_usec %= USEC;
-
- if (fr_event_timer_insert(ctx, el, &timer->ev, &next, callback, uctx) < 0) {
- return -1;
- }
+ timer->next.tv_usec += timer->rt;
+ timer->next.tv_sec += (timer->next.tv_usec / USEC);
+ timer->next.tv_usec %= USEC;
DEBUG3("RETRANSMIT - in %d.%06ds", timer->rt / USEC, timer->rt % USEC);
return 1;
}
-int rr_track_start(TALLOC_CTX *ctx, rlm_radius_retransmit_t *timer, fr_event_list_t *el,
- fr_event_cb_t callback, void *uctx)
+int rr_track_start(rlm_radius_retransmit_t *timer)
{
- struct timeval next;
-
timer->count = 1;
timer->rt = timer->retry->irt * USEC; /* rt is in usec */
- next = timer->start;
- next.tv_usec += timer->rt;
- next.tv_sec += (next.tv_usec / USEC);
- next.tv_usec %= USEC;
-
- if (fr_event_timer_insert(ctx, el, &timer->ev, &next, callback, uctx) < 0) {
- return -1;
- }
+ timer->next = timer->start;
+ timer->next.tv_usec += timer->rt;
+ timer->next.tv_sec += (timer->next.tv_usec / USEC);
+ timer->next.tv_usec %= USEC;
return 0;
}
struct timeval start; //!< when we started sending the packet
uint32_t count; //!< how many times we sent this packet
uint32_t rt; //!< retransmit timer (microseconds)
+ struct timeval next; //!< next time the timer should fire
fr_event_timer_t const *ev; //!< timer event associated with this packet
rlm_radius_retry_t *retry; //!< pointer to retry structure
} rlm_radius_retransmit_t;
int rr_track_delete(rlm_radius_id_t *id, rlm_radius_request_t *rr) CC_HINT(nonnull);
void rr_track_use_authenticator(rlm_radius_id_t *id, bool flag) CC_HINT(nonnull);
-int rr_track_start(TALLOC_CTX *ctx, rlm_radius_retransmit_t *timer, fr_event_list_t *el,
- fr_event_cb_t callback, void *uctx) CC_HINT(nonnull);
-int rr_track_retry(TALLOC_CTX *ctx, rlm_radius_retransmit_t *timer, fr_event_list_t *el,
- fr_event_cb_t callback, void *uctx,
- struct timeval *no) CC_HINT(nonnull);
+int rr_track_start(rlm_radius_retransmit_t *timer) CC_HINT(nonnull);
+int rr_track_retry(rlm_radius_retransmit_t *timer, struct timeval *now) CC_HINT(nonnull);
#endif /* _RLM_RADIUS_TRACK_H */