* do that here than to overload conn_write(), which is
* already a bit complex.
*/
+ rad_assert(u->timer.retry == &c->inst->parent->retry[u->code]);
rcode = rr_track_retry(c->id, u->rr, c->thread->el, status_check_timeout,
- u, &c->inst->parent->retry[u->code], now);
+ u, now);
if (rcode < 0) {
/*
* Failed inserting event... the request is done.
rlm_radius_udp_connection_t *c = u->c;
REQUEST *request;
- rcode = rr_track_retry(c->id, u->rr, c->thread->el, response_timeout, u, &c->inst->parent->retry[u->code], now);
+ rad_assert(u->timer.retry == &c->inst->parent->retry[u->code]);
+ rcode = rr_track_retry(c->id, u->rr, c->thread->el, response_timeout, u, now);
if (rcode < 0) {
/*
* Failed inserting event... the request is done.
RDEBUG("Proxying request. Expecting response within %d.%06ds",
u->timer.rt / USEC, u->timer.rt % USEC);
- if (rr_track_start(c->id, u->rr, c->thread->el, response_timeout, u,
- &c->inst->parent->retry[u->code]) < 0) {
+ rad_assert(u->timer.retry == &c->inst->parent->retry[u->code]);
+
+ if (rr_track_start(c->id, u->rr, c->thread->el, response_timeout, u) < 0) {
RDEBUG("Failed starting retransmit tracking");
return -1;
}
}
} else if (u->timer.count == 0) {
- if (rr_track_start(c->id, u->rr, c->thread->el, status_check_timeout,
- u, &c->inst->parent->retry[u->code]) < 0) {
+ rad_assert(u->timer.retry == &c->inst->parent->retry[u->code]);
+
+ if (rr_track_start(c->id, u->rr, c->thread->el, status_check_timeout, u) < 0) {
RDEBUG("Failed starting retransmit tracking");
return -1;
}
rlm_radius_udp_request_t *u = c->status_u;
memset(&u->timer, 0, sizeof(u->timer));
+ u->timer.retry = &c->inst->parent->retry[u->code];
+
rad_assert(u->c == c);
if (u->packet) TALLOC_FREE(u->packet);
* Reset the timer, retransmission counters, etc.
*/
if (c->status_u) {
- memset(&c->status_u->timer, 0, sizeof(c->status_u->timer));
+ rlm_radius_udp_request_t *u = c->status_u;
+
+ memset(&u->timer, 0, sizeof(u->timer));
+ u->timer.retry = &c->inst->parent->retry[u->code];
}
/*
rad_assert(c->state == CONN_ACTIVE);
rad_assert(c->num_requests < c->max_requests);
+ u->timer.retry = &c->inst->parent->retry[u->code];
u->rr = rr_track_alloc(c->id, u->link->request, u->code, u->link, &u->timer);
if (!u->rr) {
rad_assert(0 == 1);
}
int rr_track_retry(TALLOC_CTX *ctx, rlm_radius_request_t *rr, fr_event_list_t *el,
- fr_event_cb_t callback, void *uctx, rlm_radius_retry_t *retry,
+ fr_event_cb_t callback, void *uctx,
struct timeval *now)
{
uint32_t delay, frac;
/*
* We retried too many times. Fail.
*/
- if (retry->mrc && (rr->timer->count > retry->mrc)) {
- DEBUG3("RETRANSMIT - reached MRC %d", retry->mrc);
+ if (rr->timer->retry->mrc && (rr->timer->count > rr->timer->retry->mrc)) {
+ DEBUG3("RETRANSMIT - reached MRC %d", rr->timer->retry->mrc);
return 0;
}
/*
* Cap delay at MRD
*/
- if (retry->mrd) {
+ if (rr->timer->retry->mrd) {
struct timeval end;
end = rr->timer->start;
- end.tv_sec += retry->mrd;
+ end.tv_sec += rr->timer->retry->mrd;
if (timercmp(now, &end, >=)) {
- DEBUG3("RETRANSMIT - reached MRD %d", retry->mrd);
+ DEBUG3("RETRANSMIT - reached MRD %d", rr->timer->retry->mrd);
return 0;
}
}
/*
* Cap delay at MRT
*/
- if (retry->mrt && (delay > (retry->mrt * USEC))) {
- int mrt_usec = retry->mrt * USEC;
+ if (rr->timer->retry->mrt && (delay > (rr->timer->retry->mrt * USEC))) {
+ int mrt_usec = rr->timer->retry->mrt * USEC;
/*
* delay = MRT + RAND * MRT
int rr_track_start(TALLOC_CTX *ctx, rlm_radius_request_t *rr, fr_event_list_t *el,
- fr_event_cb_t callback, void *uctx, rlm_radius_retry_t *retry)
+ fr_event_cb_t callback, void *uctx)
{
struct timeval next;
rr->timer->count = 1;
- rr->timer->rt = retry->irt * USEC; /* rt is in usec */
+ rr->timer->rt = rr->timer->retry->irt * USEC; /* rt is in usec */
next = rr->timer->start;
next.tv_usec += rr->timer->rt;
uint32_t count; //!< how many times we sent this packet
uint32_t rt; //!< retransmit timer (microseconds)
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;
/** Track one request to a response
void rr_track_use_authenticator(rlm_radius_id_t *id, bool flag) CC_HINT(nonnull);
int rr_track_start(TALLOC_CTX *ctx, rlm_radius_request_t *rr, fr_event_list_t *el,
- fr_event_cb_t callback, void *uctx, rlm_radius_retry_t *retry) CC_HINT(nonnull);
+ fr_event_cb_t callback, void *uctx) CC_HINT(nonnull);
int rr_track_retry(TALLOC_CTX *ctx, rlm_radius_request_t *rr, fr_event_list_t *el,
- fr_event_cb_t callback, void *uctx, rlm_radius_retry_t *retry,
+ fr_event_cb_t callback, void *uctx,
struct timeval *no) CC_HINT(nonnull);
#endif /* _RLM_RADIUS_TRACK_H */