aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2016-10-11 09:37:20 +0200
committerGravatar Christian Hesse <mail@eworm.de>2016-10-11 09:37:20 +0200
commitd1fb448d92233686c1ee09548938372a3d3d7766 (patch)
treeb1110a65cf777be92d6ec9c5ed91e689a9428361
parentdd010391dd3f18cbf6ef5fc43995b423cc831955 (diff)
downloadpaccache-d1fb448d92233686c1ee09548938372a3d3d7766.tar.gz
paccache-d1fb448d92233686c1ee09548938372a3d3d7766.tar.zst
initialize struct timeval just once
-rw-r--r--pacredir.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/pacredir.c b/pacredir.c
index 81256b0..1677172 100644
--- a/pacredir.c
+++ b/pacredir.c
@@ -316,6 +316,9 @@ static int ahc_echo(void * cls,
double time_total = INFINITY;
char ctime[26];
+ /* initialize struct timeval */
+ gettimeofday(&tv, NULL);
+
/* we want the filename, not the path */
basename = uri;
while (strstr(basename, "/") != NULL)
@@ -366,8 +369,6 @@ static int ahc_echo(void * cls,
/* try to find a server with most recent file */
while (tmphosts->host != NULL) {
- gettimeofday(&tv, NULL);
-
/* skip host if offline or had a bad request within last BADTIME seconds */
if ((dbfile == 1 && (tmphosts->pacdbserve.online == 0 || tmphosts->pacdbserve.badtime + tmphosts->pacdbserve.badcount * BADTIME > tv.tv_sec)) ||
(dbfile == 0 && (tmphosts->pacserve.online == 0 || tmphosts->pacserve.badtime + tmphosts->pacserve.badcount * BADTIME > tv.tv_sec))) {