Commit 2b5685c6 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Use a timeval for request_resend_time.

parent e278342e
......@@ -531,8 +531,7 @@ main(int argc, char **argv)
tv = check_neighbours_time;
timeval_min_sec(&tv, expiry_time);
if(request_resend_time)
timeval_min_sec(&tv, request_resend_time);
timeval_min(&tv, &request_resend_time);
for(i = 0; i < numnets; i++) {
if(!nets[i].up)
continue;
......@@ -658,7 +657,7 @@ main(int argc, char **argv)
}
}
if(now.tv_sec >= request_resend_time)
if(timeval_compare(&now, &request_resend_time) >= 0)
resend_requests();
if(update_flush_timeout.tv_sec != 0) {
......
......@@ -33,7 +33,7 @@ THE SOFTWARE.
#include "network.h"
#include "filter.h"
int request_resend_time = 0;
struct timeval request_resend_time = {0, 0};
struct request *recorded_requests = NULL;
static int
......@@ -83,7 +83,7 @@ record_request(const unsigned char *prefix, unsigned char plen,
else if(resend)
request->resend = resend;
request->time = now.tv_sec;
request_resend_time = MIN(request_resend_time,
timeval_min_sec(&request_resend_time,
request->time + request->resend);
if(request->router_hash == router_hash &&
seqno_compare(request->seqno, seqno) > 0) {
......@@ -107,7 +107,7 @@ record_request(const unsigned char *prefix, unsigned char plen,
request->time = now.tv_sec;
request->resend = resend;
if(resend)
request_resend_time = MIN(request_resend_time, now.tv_sec + resend);
timeval_min_sec(&request_resend_time, now.tv_sec + resend);
request->next = recorded_requests;
recorded_requests = request;
return 1;
......@@ -187,25 +187,20 @@ expire_requests()
recompute_request_resend_time();
}
int
void
recompute_request_resend_time()
{
struct request *request;
int resend = 0;
struct timeval resend = {0, 0};
request = recorded_requests;
while(request) {
if(request->resend) {
if(resend)
resend = MIN(resend, request->time + request->resend);
else
resend = request->time + request->resend;
}
if(request->resend)
timeval_min_sec(&resend, request->time + request->resend);
request = request->next;
}
request_resend_time = resend;
return resend;
}
void
......
......@@ -33,7 +33,7 @@ struct request {
struct request *next;
};
extern int request_resend_time;
extern struct timeval request_resend_time;
struct request *find_request(const unsigned char *prefix, unsigned char plen,
struct request **previous_return);
......@@ -47,5 +47,5 @@ int satisfy_request(const unsigned char *prefix, unsigned char plen,
struct network *net);
void expire_requests(void);
int recompute_request_resend_time(void);
void recompute_request_resend_time(void);
void resend_requests(void);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment