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) ...@@ -531,8 +531,7 @@ main(int argc, char **argv)
tv = check_neighbours_time; tv = check_neighbours_time;
timeval_min_sec(&tv, expiry_time); timeval_min_sec(&tv, expiry_time);
if(request_resend_time) timeval_min(&tv, &request_resend_time);
timeval_min_sec(&tv, request_resend_time);
for(i = 0; i < numnets; i++) { for(i = 0; i < numnets; i++) {
if(!nets[i].up) if(!nets[i].up)
continue; continue;
...@@ -658,7 +657,7 @@ main(int argc, char **argv) ...@@ -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(); resend_requests();
if(update_flush_timeout.tv_sec != 0) { if(update_flush_timeout.tv_sec != 0) {
......
...@@ -33,7 +33,7 @@ THE SOFTWARE. ...@@ -33,7 +33,7 @@ THE SOFTWARE.
#include "network.h" #include "network.h"
#include "filter.h" #include "filter.h"
int request_resend_time = 0; struct timeval request_resend_time = {0, 0};
struct request *recorded_requests = NULL; struct request *recorded_requests = NULL;
static int static int
...@@ -83,8 +83,8 @@ record_request(const unsigned char *prefix, unsigned char plen, ...@@ -83,8 +83,8 @@ record_request(const unsigned char *prefix, unsigned char plen,
else if(resend) else if(resend)
request->resend = resend; request->resend = resend;
request->time = now.tv_sec; request->time = now.tv_sec;
request_resend_time = MIN(request_resend_time, timeval_min_sec(&request_resend_time,
request->time + request->resend); request->time + request->resend);
if(request->router_hash == router_hash && if(request->router_hash == router_hash &&
seqno_compare(request->seqno, seqno) > 0) { seqno_compare(request->seqno, seqno) > 0) {
return 0; return 0;
...@@ -107,7 +107,7 @@ record_request(const unsigned char *prefix, unsigned char plen, ...@@ -107,7 +107,7 @@ record_request(const unsigned char *prefix, unsigned char plen,
request->time = now.tv_sec; request->time = now.tv_sec;
request->resend = resend; request->resend = resend;
if(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; request->next = recorded_requests;
recorded_requests = request; recorded_requests = request;
return 1; return 1;
...@@ -187,25 +187,20 @@ expire_requests() ...@@ -187,25 +187,20 @@ expire_requests()
recompute_request_resend_time(); recompute_request_resend_time();
} }
int void
recompute_request_resend_time() recompute_request_resend_time()
{ {
struct request *request; struct request *request;
int resend = 0; struct timeval resend = {0, 0};
request = recorded_requests; request = recorded_requests;
while(request) { while(request) {
if(request->resend) { if(request->resend)
if(resend) timeval_min_sec(&resend, request->time + request->resend);
resend = MIN(resend, request->time + request->resend);
else
resend = request->time + request->resend;
}
request = request->next; request = request->next;
} }
request_resend_time = resend; request_resend_time = resend;
return resend;
} }
void void
......
...@@ -33,7 +33,7 @@ struct request { ...@@ -33,7 +33,7 @@ struct request {
struct request *next; 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 *find_request(const unsigned char *prefix, unsigned char plen,
struct request **previous_return); struct request **previous_return);
...@@ -47,5 +47,5 @@ int satisfy_request(const unsigned char *prefix, unsigned char plen, ...@@ -47,5 +47,5 @@ int satisfy_request(const unsigned char *prefix, unsigned char plen,
struct network *net); struct network *net);
void expire_requests(void); void expire_requests(void);
int recompute_request_resend_time(void); void recompute_request_resend_time(void);
void resend_requests(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