Skip to content

Commit

Permalink
fix timeout for -p N. Fixes #5106
Browse files Browse the repository at this point in the history
  • Loading branch information
alandekok committed Jul 12, 2023
1 parent 3f1c4da commit 9647ad0
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/main/radclient.c
Expand Up @@ -1562,13 +1562,23 @@ int main(int argc, char **argv)
int n = parallel;
rc_request_t *next;
char const *filename = NULL;
time_t wake = 0;

done = true;
sleep_time = -1;

/*
* Walk over the packets, sending them.
*/
for (this = request_head; this != NULL; this = this->next) {
if (this->reply) continue;

if (!this->timestamp) continue;

if (!wake || (wake > (this->timestamp + ((int) timeout) * (retries - this->tries)))) {
wake = this->timestamp + ((int) timeout) * (retries - this->tries);
}
}

for (this = request_head; this != NULL; this = next) {
next = this->next;
Expand Down Expand Up @@ -1613,6 +1623,10 @@ int main(int argc, char **argv)
break;
}

if (!wake || (wake > (this->timestamp + ((int) timeout) * (retries - this->tries)))) {
wake = this->timestamp + ((int) timeout) * (retries - this->tries);
}

/*
* Wait a little before sending
* the next packet, if told to.
Expand Down Expand Up @@ -1664,7 +1678,18 @@ int main(int argc, char **argv)
* Still have outstanding requests.
*/
if (fr_packet_list_num_elements(pl) > 0) {
time_t now = time(NULL);
done = false;

/*
* The last time we wake up for a packet.
*
* If we're past that time, then give up.
*/
if (wake < now) {
break;
}

} else {
sleep_time = 0;
}
Expand Down

0 comments on commit 9647ad0

Please sign in to comment.