From 5c4409a9f2dd0a26dc706898887e7dcdbe7f9ab4 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 15 Nov 2013 09:17:18 +0100 Subject: rename services.bad to something more descriptive --- pacredir.c | 20 ++++++++++---------- pacredir.h | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pacredir.c b/pacredir.c index 8079421..343e107 100644 --- a/pacredir.c +++ b/pacredir.c @@ -92,10 +92,10 @@ int add_host(const char * host, const char * type) { write_log(stdout, "Adding host %s with service %s\n", host, type); tmphosts->host = strdup(host); tmphosts->pacserve.online = 0; - tmphosts->pacserve.bad = 0; + tmphosts->pacserve.badtime = 0; tmphosts->pacserve.badcount = 0; tmphosts->pacdbserve.online = 0; - tmphosts->pacdbserve.bad = 0; + tmphosts->pacdbserve.badtime = 0; tmphosts->pacdbserve.badcount = 0; tmphosts->next = malloc(sizeof(struct hosts)); tmphosts->next->host = NULL; @@ -247,11 +247,11 @@ static void * get_http_code(void * data) { write_log(stderr, "Could not connect to server %s on port %d.\n", request->host, request->port); request->http_code = 0; request->last_modified = 0; - request->service->bad = tv.tv_sec; + request->service->badtime = tv.tv_sec; request->service->badcount++; return NULL; } else { - request->service->bad = 0; + request->service->badtime = 0; request->service->badcount = 0; } @@ -344,8 +344,8 @@ static int ahc_echo(void * cls, struct MHD_Connection * connection, const char * 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.bad + tmphosts->pacdbserve.badcount * BADTIME > tv.tv_sec)) || - (dbfile == 0 && (tmphosts->pacserve.online == 0 || tmphosts->pacserve.bad + tmphosts->pacserve.bad * BADTIME > tv.tv_sec))) { + 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))) { tmphosts = tmphosts->next; continue; } @@ -442,9 +442,9 @@ void sighup_callback(int signal) { write_log(stdout, "Received SIGHUP, resetting bad status for hosts.\n"); while (tmphosts->host != NULL) { - tmphosts->pacserve.bad = 0; + tmphosts->pacserve.badtime = 0; tmphosts->pacserve.badcount = 0; - tmphosts->pacdbserve.bad = 0; + tmphosts->pacdbserve.badtime = 0; tmphosts->pacdbserve.badcount = 0; tmphosts = tmphosts->next; } @@ -469,9 +469,9 @@ int main(int argc, char ** argv) { hosts = malloc(sizeof(struct hosts)); hosts->host = NULL; hosts->pacserve.online = 0; - hosts->pacserve.bad = 0; + hosts->pacserve.badtime = 0; hosts->pacdbserve.online = 0; - hosts->pacdbserve.bad = 0; + hosts->pacdbserve.badtime = 0; hosts->next = NULL; ignore_interfaces = malloc(sizeof(struct ignore_interfaces)); diff --git a/pacredir.h b/pacredir.h index 5f3fbb9..3b692e3 100644 --- a/pacredir.h +++ b/pacredir.h @@ -13,7 +13,7 @@ struct services { /* true if host/service is online */ uint8_t online; /* unix timestamp of last bad request */ - __time_t bad; + __time_t badtime; /* count the number of bad requests */ unsigned int badcount; }; -- cgit v1.2.3-70-g09d2