Skip to content

Commit

Permalink
Only start the response timer if we manage to write out a packet
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed Feb 24, 2020
1 parent 175bb4f commit cec1389
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/modules/rlm_radius/rlm_radius_udp.c
Expand Up @@ -1258,6 +1258,7 @@ static int write_packet(fr_event_list_t *el, fr_trunk_request_t *treq, uint8_t c
udp_handle_t *h = talloc_get_type_abort(treq->tconn->conn->h, udp_handle_t);
REQUEST *request = treq->request;
rlm_radius_udp_t const *inst = h->inst;
uint32_t msec = 0;

/*
* Tell the admin what's going on
Expand All @@ -1272,18 +1273,10 @@ static int write_packet(fr_event_list_t *el, fr_trunk_request_t *treq, uint8_t c
}

if (!inst->parent->synchronous) {
uint32_t msec = fr_time_delta_to_msec(u->retry.rt);
msec = fr_time_delta_to_msec(u->retry.rt);

RDEBUG("%s request. Expecting response within %u.%03us",
action, msec / 1000, msec % 1000);

/*
* Set up a timer for retransmits.
*/
if (fr_event_timer_at(u, el, &u->ev, u->retry.next, request_timeout, treq) < 0) {
RERROR("Failed inserting retransmit timeout for connection");
return -1;
}
} else {
/*
* If the packet doesn't get a response,
Expand Down Expand Up @@ -1311,6 +1304,17 @@ static int write_packet(fr_event_list_t *el, fr_trunk_request_t *treq, uint8_t c
}
rad_assert((size_t) slen == packet_len); /* Should never get partial writes with UDP */

/*
* Set up a timer for retransmits
* Only do this *AFTER* we've successfully written the packet.
*/
if (msec > 0) {
if (fr_event_timer_at(u, el, &u->ev, u->retry.next, request_timeout, treq) < 0) {
RERROR("Failed inserting retransmit timeout for connection");
return -1;
}
}

return 0;
}

Expand Down

0 comments on commit cec1389

Please sign in to comment.