From cd196bc825b265de3412837f3c706d6d3506bad4 Mon Sep 17 00:00:00 2001 From: wessels <> Date: Tue, 15 Sep 1998 03:58:45 +0000 Subject: [PATCH] replaced NEIGHBOR_ and HELPER_ EBIT calls --- src/authenticate.cc | 33 ++++++++++++++++++--------------- src/cache_cf.cc | 22 +++++++++++----------- src/dns.cc | 37 ++++++++++++++++++++----------------- src/enums.h | 27 +-------------------------- src/fqdncache.cc | 17 ++++++++++------- src/http.cc | 6 +++--- src/ipcache.cc | 17 ++++++++++------- src/neighbors.cc | 40 ++++++++++++++++++++-------------------- src/peer_digest.cc | 4 ++-- src/peer_select.cc | 6 +++--- src/redirect.cc | 33 ++++++++++++++++++--------------- src/structs.h | 28 +++++++++++++++++++++++++--- src/typedefs.h | 3 ++- 13 files changed, 143 insertions(+), 130 deletions(-) diff --git a/src/authenticate.cc b/src/authenticate.cc index 28c3419db3..323b6eed52 100644 --- a/src/authenticate.cc +++ b/src/authenticate.cc @@ -1,6 +1,6 @@ /* - * $Id: authenticate.cc,v 1.3 1998/09/04 23:04:38 wessels Exp $ + * $Id: authenticate.cc,v 1.4 1998/09/14 21:58:45 wessels Exp $ * * DEBUG: section 29 Authenticator * AUTHOR: Duane Wessels @@ -43,7 +43,7 @@ typedef struct { typedef struct _authenticator { int index; - int flags; + helper_flags flags; int fd; char *inbuf; unsigned int size; @@ -100,10 +100,13 @@ authenticateHandleRead(int fd, void *data) if (len <= 0) { if (len < 0) debug(50, 1) ("authenticateHandleRead: FD %d read: %s\n", fd, xstrerror()); - debug(29, EBIT_TEST(authenticator->flags, HELPER_CLOSING) ? 5 : 1) + debug(29, authenticator->flags.closing ? 5 : 1) ("FD %d: Connection from Authenticator #%d is closed, disabling\n", fd, authenticator->index + 1); - authenticator->flags = 0; + authenticator->flags.alive = 0; + authenticator->flags.busy = 0; + authenticator->flags.closing = 0; + authenticator->flags.shutdown = 0; memFree(MEM_8K_BUF, authenticator->inbuf); authenticator->inbuf = NULL; comm_close(fd); @@ -143,7 +146,7 @@ authenticateHandleRead(int fd, void *data) } authenticateStateFree(r); authenticator->authenticateState = NULL; - EBIT_CLR(authenticator->flags, HELPER_BUSY); + authenticator->flags.busy = 0; authenticator->offset = 0; n = ++AuthenticateStats.replies; AuthenticateStats.avg_svc_time = @@ -190,9 +193,9 @@ GetFirstAvailable(void) authenticator_t *authenticate = NULL; for (k = 0; k < NAuthenticators; k++) { authenticate = *(authenticate_child_table + k); - if (EBIT_TEST(authenticate->flags, HELPER_BUSY)) + if (authenticate->flags.busy) continue; - if (!EBIT_TEST(authenticate->flags, HELPER_ALIVE)) + if (!authenticate->flags.alive) continue; return authenticate; } @@ -217,7 +220,7 @@ authenticateDispatch(authenticator_t * authenticate, authenticateStateData * r) authenticateStateFree(r); return; } - EBIT_SET(authenticate->flags, HELPER_BUSY); + authenticate->flags.busy = 1; authenticate->authenticateState = r; authenticate->dispatch_time = current_time; buf = memAllocate(MEM_8K_BUF); @@ -331,9 +334,9 @@ authenticateOpenServers(void) &authenticatesocket); if (x < 0) { debug(29, 1) ("WARNING: Cannot run '%s' process.\n", prg); - EBIT_CLR(authenticate_child_table[k]->flags, HELPER_ALIVE); + authenticate_child_table[k]->flags.alive = 0; } else { - EBIT_SET(authenticate_child_table[k]->flags, HELPER_ALIVE); + authenticate_child_table[k]->flags.alive = 1; authenticate_child_table[k]->index = k; authenticate_child_table[k]->fd = authenticatesocket; authenticate_child_table[k]->inbuf = memAllocate(MEM_8K_BUF); @@ -380,19 +383,19 @@ authenticateShutdownServers(void *unused) } for (k = 0; k < NAuthenticators; k++) { authenticate = *(authenticate_child_table + k); - if (!EBIT_TEST(authenticate->flags, HELPER_ALIVE)) + if (!authenticate->flags.alive) continue; - if (EBIT_TEST(authenticate->flags, HELPER_CLOSING)) + if (authenticate->flags.closing) continue; - if (EBIT_TEST(authenticate->flags, HELPER_BUSY)) { + if (authenticate->flags.busy) { na++; continue; } debug(29, 3) ("authenticateShutdownServers: closing authenticator #%d, FD %d\n", authenticate->index + 1, authenticate->fd); comm_close(authenticate->fd); - EBIT_SET(authenticate->flags, HELPER_CLOSING); - EBIT_SET(authenticate->flags, HELPER_BUSY); + authenticate->flags.closing = 1; + authenticate->flags.busy = 1; } if (na) eventAdd("authenticateShutdownServers", authenticateShutdownServers, NULL, 1.0, 1); diff --git a/src/cache_cf.cc b/src/cache_cf.cc index c58a665202..b88f1bde44 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.cc,v 1.304 1998/09/01 22:12:06 wessels Exp $ + * $Id: cache_cf.cc,v 1.305 1998/09/14 21:58:46 wessels Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -770,17 +770,17 @@ parse_peer(peer ** head) } while ((token = strtok(NULL, w_space))) { if (!strcasecmp(token, "proxy-only")) { - EBIT_SET(p->options, NEIGHBOR_PROXY_ONLY); + p->options.proxy_only = 1; } else if (!strcasecmp(token, "no-query")) { - EBIT_SET(p->options, NEIGHBOR_NO_QUERY); + p->options.no_query = 1; } else if (!strcasecmp(token, "no-digest")) { - EBIT_SET(p->options, NEIGHBOR_NO_DIGEST); + p->options.no_digest = 1; } else if (!strcasecmp(token, "multicast-responder")) { - EBIT_SET(p->options, NEIGHBOR_MCAST_RESPONDER); + p->options.mcast_responder = 1; } else if (!strncasecmp(token, "weight=", 7)) { p->weight = atoi(token + 7); } else if (!strcasecmp(token, "closest-only")) { - EBIT_SET(p->options, NEIGHBOR_CLOSEST_ONLY); + p->options.closest_only = 1; } else if (!strncasecmp(token, "ttl=", 4)) { p->mcast.ttl = atoi(token + 4); if (p->mcast.ttl < 0) @@ -788,15 +788,15 @@ parse_peer(peer ** head) if (p->mcast.ttl > 128) p->mcast.ttl = 128; } else if (!strcasecmp(token, "default")) { - EBIT_SET(p->options, NEIGHBOR_DEFAULT_PARENT); + p->options.default_parent = 1; } else if (!strcasecmp(token, "round-robin")) { - EBIT_SET(p->options, NEIGHBOR_ROUNDROBIN); + p->options.roundrobin = 1; #if USE_HTCP } else if (!strcasecmp(token, "htcp")) { - EBIT_SET(p->options, NEIGHBOR_HTCP); + p->options.htcp = 1; #endif } else if (!strcasecmp(token, "no-netdb-exchange")) { - EBIT_SET(p->options, NEIGHBOR_NO_NETDB_EXCHANGE); + p->options.no_netdb_exchange = 1; #if USE_CARP } else if (!strncasecmp(token, "carp-load-factor=", 17)) { if (p->type != PEER_PARENT) @@ -806,7 +806,7 @@ parse_peer(peer ** head) #endif #if DELAY_POOLS } else if (!strcasecmp(token, "no-delay")) { - EBIT_SET(p->options, NEIGHBOR_NO_DELAY); + p->options.no_delay = 1; #endif } else { debug(3, 0) ("parse_peer: token='%s'\n", token); diff --git a/src/dns.cc b/src/dns.cc index 1c7d6f8ebd..b9eac8429c 100644 --- a/src/dns.cc +++ b/src/dns.cc @@ -1,6 +1,6 @@ /* - * $Id: dns.cc,v 1.63 1998/07/29 03:57:37 wessels Exp $ + * $Id: dns.cc,v 1.64 1998/09/14 21:58:47 wessels Exp $ * * DEBUG: section 34 Dnsserver interface * AUTHOR: Harvest Derived @@ -65,11 +65,11 @@ dnsGetFirstAvailable(void) dnsserver_t *dns = NULL; for (k = 0; k < NDnsServersAlloc; k++) { dns = *(dns_child_table + k); - if (EBIT_TEST(dns->flags, HELPER_BUSY)) + if (dns->flags.busy) continue; - if (EBIT_TEST(dns->flags, HELPER_CLOSING)) + if (dns->flags.closing) continue; - if (!EBIT_TEST(dns->flags, HELPER_ALIVE)) + if (!dns->flags.alive) continue; return dns; } @@ -131,14 +131,14 @@ dnsOpenServers(void) &wfd); if (x < 0) { debug(34, 1) ("dnsOpenServers: WARNING: Failed to start 'dnsserver' #%d.\n", k + 1); - EBIT_CLR(dns_child_table[k]->flags, HELPER_ALIVE); + dns_child_table[k]->flags.alive = 0; dns_child_table[k]->id = k + 1; dns_child_table[k]->inpipe = -1; dns_child_table[k]->outpipe = -1; } else { debug(34, 4) ("dnsOpenServers: FD %d connected to %s #%d.\n", wfd, prg, k + 1); - EBIT_SET(dns_child_table[k]->flags, HELPER_ALIVE); + dns_child_table[k]->flags.alive = 1; dns_child_table[k]->id = k + 1; dns_child_table[k]->inpipe = rfd; dns_child_table[k]->outpipe = wfd; @@ -196,10 +196,10 @@ dnsStats(StoreEntry * sentry) k + 1, dns->inpipe, DnsStats.hist[k], - EBIT_TEST(dns->flags, HELPER_ALIVE) ? 'A' : ' ', - EBIT_TEST(dns->flags, HELPER_BUSY) ? 'B' : ' ', - EBIT_TEST(dns->flags, HELPER_CLOSING) ? 'C' : ' ', - EBIT_TEST(dns->flags, HELPER_SHUTDOWN) ? 'S' : ' ', + dns->flags.alive ? 'A' : ' ', + dns->flags.busy ? 'B' : ' ', + dns->flags.closing ? 'C' : ' ', + dns->flags.shutdown ? 'S' : ' ', 0.001 * tvSubMsec(dns->dispatch_time, current_time), (int) dns->offset); } @@ -218,17 +218,17 @@ dnsShutdownServers(void *notused) debug(34, 3) ("dnsShutdownServers:\n"); for (k = 0; k < NDnsServersAlloc; k++) { dns = *(dns_child_table + k); - if (!EBIT_TEST(dns->flags, HELPER_ALIVE)) { + if (!dns->flags.alive) { debug(34, 3) ("dnsShutdownServers: #%d is NOT ALIVE.\n", dns->id); continue; } - if (EBIT_TEST(dns->flags, HELPER_BUSY)) { + if (dns->flags.busy) { debug(34, 3) ("dnsShutdownServers: #%d is BUSY.\n", dns->id); - EBIT_SET(dns->flags, HELPER_SHUTDOWN); + dns->flags.shutdown = 1; na++; continue; } - if (EBIT_TEST(dns->flags, HELPER_CLOSING)) { + if (dns->flags.closing) { debug(34, 3) ("dnsShutdownServers: #%d is CLOSING.\n", dns->id); continue; } @@ -266,18 +266,21 @@ dnsShutdownServer(dnsserver_t * dns) dnsShutdownRead, dns, 0); - EBIT_SET(dns->flags, HELPER_CLOSING); + dns->flags.closing = 1; } static void dnsShutdownRead(int fd, void *data) { dnsserver_t *dns = data; - debug(14, EBIT_TEST(dns->flags, HELPER_CLOSING) ? 5 : 1) + debug(14, dns->flags.closing ? 5 : 1) ("FD %d: Connection from DNSSERVER #%d is closed, disabling\n", fd, dns->id); - dns->flags = 0; + dns->flags.alive = 0; + dns->flags.busy = 0; + dns->flags.closing = 0; + dns->flags.shutdown = 0; commSetSelect(fd, COMM_SELECT_WRITE, NULL, NULL, 0); cbdataUnlock(dns); comm_close(fd); diff --git a/src/enums.h b/src/enums.h index 15676fb02e..2f054933ce 100644 --- a/src/enums.h +++ b/src/enums.h @@ -1,6 +1,6 @@ /* - * $Id: enums.h,v 1.127 1998/09/14 21:28:01 wessels Exp $ + * $Id: enums.h,v 1.128 1998/09/14 21:58:47 wessels Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -445,31 +445,6 @@ enum { ERR_FLAG_CBDATA }; -enum { - HELPER_ALIVE, - HELPER_BUSY, - HELPER_CLOSING, - HELPER_SHUTDOWN -}; - -enum { - NEIGHBOR_PROXY_ONLY, - NEIGHBOR_NO_QUERY, - NEIGHBOR_NO_DIGEST, - NEIGHBOR_DEFAULT_PARENT, - NEIGHBOR_ROUNDROBIN, - NEIGHBOR_MCAST_RESPONDER, - NEIGHBOR_CLOSEST_ONLY, -#if USE_HTCP - NEIGHBOR_HTCP, -#endif - NEIGHBOR_NO_NETDB_EXCHANGE, -#if DELAY_POOLS - NEIGHBOR_NO_DELAY, -#endif - NEIGHBOR_END -}; - typedef enum { ACCESS_DENIED, ACCESS_ALLOWED, diff --git a/src/fqdncache.cc b/src/fqdncache.cc index 17f3dc3e97..d7ef8d5bf9 100644 --- a/src/fqdncache.cc +++ b/src/fqdncache.cc @@ -1,7 +1,7 @@ /* - * $Id: fqdncache.cc,v 1.114 1998/09/04 23:04:44 wessels Exp $ + * $Id: fqdncache.cc,v 1.115 1998/09/14 21:58:48 wessels Exp $ * * DEBUG: section 35 FQDN Cache * AUTHOR: Harvest Derived @@ -359,10 +359,13 @@ fqdncache_dnsHandleRead(int fd, void *data) dnsData, 0); return; } - debug(35, EBIT_TEST(dnsData->flags, HELPER_CLOSING) ? 5 : 1) + debug(35, dnsData->flags.closing ? 5 : 1) ("FD %d: Connection from DNSSERVER #%d is closed, disabling\n", fd, dnsData->id); - dnsData->flags = 0; + dnsData->flags.alive = 0; + dnsData->flags.busy = 0; + dnsData->flags.closing = 0; + dnsData->flags.shutdown = 0; commSetSelect(fd, COMM_SELECT_WRITE, NULL, @@ -406,8 +409,8 @@ fqdncache_dnsHandleRead(int fd, void *data) } if (dnsData->offset == 0) { dnsData->data = NULL; - EBIT_CLR(dnsData->flags, HELPER_BUSY); - if (EBIT_TEST(dnsData->flags, HELPER_SHUTDOWN)) + dnsData->flags.busy = 0; + if (dnsData->flags.shutdown) dnsShutdownServer(dnsData); cbdataUnlock(dnsData); } @@ -499,7 +502,7 @@ static void fqdncache_dnsDispatch(dnsserver_t * dns, fqdncache_entry * f) { char *buf = NULL; - assert(EBIT_TEST(dns->flags, HELPER_ALIVE)); + assert(dns->flags.alive); if (!fqdncacheHasPending(f)) { debug(35, 0) ("fqdncache_dnsDispatch: skipping '%s' because no handler.\n", f->name); @@ -511,7 +514,7 @@ fqdncache_dnsDispatch(dnsserver_t * dns, fqdncache_entry * f) debug_trap("fqdncache_dnsDispatch: status != FQDN_PENDING"); buf = xcalloc(1, 256); snprintf(buf, 256, "%s\n", f->name); - EBIT_SET(dns->flags, HELPER_BUSY); + dns->flags.busy = 1; dns->data = f; f->status = FQDN_DISPATCHED; comm_write(dns->outpipe, diff --git a/src/http.cc b/src/http.cc index d6ef68c5ab..f216be4a52 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.317 1998/09/14 21:28:05 wessels Exp $ + * $Id: http.cc,v 1.318 1998/09/14 21:58:49 wessels Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -795,10 +795,10 @@ httpStart(FwdState * fwdState, int fd) * We might end up getting the object from somewhere else if, * for example, the request to this neighbor fails. */ - if (EBIT_TEST(httpState->peer->options, NEIGHBOR_PROXY_ONLY)) + if (httpState->peer->options.proxy_only) storeReleaseRequest(httpState->entry); #if DELAY_POOLS - if (EBIT_TEST(httpState->peer->options, NEIGHBOR_NO_DELAY)) { + if (httpState->peer->options.no_delay) { proxy_req->delay_id = 0; } else { proxy_req->delay_id = orig_req->delay_id; diff --git a/src/ipcache.cc b/src/ipcache.cc index e7ac8d1c06..b0ce85ce2a 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -1,6 +1,6 @@ /* - * $Id: ipcache.cc,v 1.200 1998/09/04 23:04:54 wessels Exp $ + * $Id: ipcache.cc,v 1.201 1998/09/14 21:58:50 wessels Exp $ * * DEBUG: section 14 IP Cache * AUTHOR: Harvest Derived @@ -409,10 +409,13 @@ ipcache_dnsHandleRead(int fd, void *data) 0); return; } - debug(14, EBIT_TEST(dnsData->flags, HELPER_CLOSING) ? 5 : 1) + debug(14, dnsData->flags.closing ? 5 : 1) ("FD %d: Connection from DNSSERVER #%d is closed, disabling\n", fd, dnsData->id); - dnsData->flags = 0; + dnsData->flags.alive = 0; + dnsData->flags.busy = 0; + dnsData->flags.closing = 0; + dnsData->flags.shutdown = 0; commSetSelect(fd, COMM_SELECT_WRITE, NULL, NULL, 0); comm_close(fd); return; @@ -450,8 +453,8 @@ ipcache_dnsHandleRead(int fd, void *data) } if (dnsData->offset == 0) { dnsData->data = NULL; - EBIT_CLR(dnsData->flags, HELPER_BUSY); - if (EBIT_TEST(dnsData->flags, HELPER_SHUTDOWN)) + dnsData->flags.busy = 0; + if (dnsData->flags.shutdown) dnsShutdownServer(dnsData); cbdataUnlock(dnsData); } @@ -545,7 +548,7 @@ static void ipcache_dnsDispatch(dnsserver_t * dns, ipcache_entry * i) { char *buf = NULL; - assert(EBIT_TEST(dns->flags, HELPER_ALIVE)); + assert(dns->flags.alive); if (!ipcacheHasPending(i)) { debug(14, 3) ("Skipping lookup of '%s' because client(s) disappeared.\n", i->name); @@ -556,7 +559,7 @@ ipcache_dnsDispatch(dnsserver_t * dns, ipcache_entry * i) assert(i->status == IP_PENDING); buf = xcalloc(1, 256); snprintf(buf, 256, "%s\n", i->name); - EBIT_SET(dns->flags, HELPER_BUSY); + dns->flags.busy = 1; dns->data = i; i->status = IP_DISPATCHED; cbdataLock(dns); diff --git a/src/neighbors.cc b/src/neighbors.cc index 701a386c8b..b7bddd2529 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -1,6 +1,6 @@ /* - * $Id: neighbors.cc,v 1.246 1998/09/14 21:28:06 wessels Exp $ + * $Id: neighbors.cc,v 1.247 1998/09/14 21:58:51 wessels Exp $ * * DEBUG: section 15 Neighbor Routines * AUTHOR: Harvest Derived @@ -153,9 +153,9 @@ peerWouldBePinged(const peer * p, request_t * request) { if (!peerAllowedToUse(p, request)) return 0; - if (EBIT_TEST(p->options, NEIGHBOR_NO_QUERY)) + if (p->options.no_query) return 0; - if (EBIT_TEST(p->options, NEIGHBOR_MCAST_RESPONDER)) + if (p->options.mcast_responder) return 0; /* the case below seems strange, but can happen if the * URL host is on the other side of a firewall */ @@ -207,7 +207,7 @@ getSingleParent(request_t * request) return NULL; /* oops, found second parent */ p = q; } - if (p != NULL && !EBIT_TEST(p->options, NEIGHBOR_NO_QUERY)) + if (p != NULL && !p->options.no_query) return NULL; debug(15, 3) ("getSingleParent: returning %s\n", p ? p->host : "NULL"); return p; @@ -236,7 +236,7 @@ getRoundRobinParent(request_t * request) peer *p; peer *q = NULL; for (p = Config.peers; p; p = p->next) { - if (!EBIT_TEST(p->options, NEIGHBOR_ROUNDROBIN)) + if (!p->options.roundrobin) continue; if (neighborType(p, request) != PEER_PARENT) continue; @@ -259,7 +259,7 @@ getDefaultParent(request_t * request) for (p = Config.peers; p; p = p->next) { if (neighborType(p, request) != PEER_PARENT) continue; - if (!EBIT_TEST(p->options, NEIGHBOR_DEFAULT_PARENT)) + if (!p->options.default_parent) continue; if (!peerHTTPOkay(p, request)) continue; @@ -376,7 +376,7 @@ neighborsUdpPing(request_t * request, debug(15, 3) ("neighborsUdpPing: reqnum = %d\n", reqnum); #if USE_HTCP - if (EBIT_TEST(p->options, NEIGHBOR_HTCP)) { + if (p->options.htcp) { debug(15, 3) ("neighborsUdpPing: sending HTCP query\n"); htcpQuery(entry, request, p); } else @@ -684,7 +684,7 @@ ignoreMulticastReply(peer * p, MemObject * mem) { if (p == NULL) return 0; - if (!EBIT_TEST(p->options, NEIGHBOR_MCAST_RESPONDER)) + if (!p->options.mcast_responder) return 0; if (peerHTTPOkay(p, mem->request)) return 0; @@ -882,7 +882,7 @@ peerDNSConfigure(const ipcache_addrs * ia, void *data) if (p->type == PEER_MULTICAST) peerCountMcastPeersSchedule(p, 10); if (p->type != PEER_MULTICAST) - if (!EBIT_TEST(p->options, NEIGHBOR_NO_NETDB_EXCHANGE)) + if (!p->options.no_netdb_exchange) eventAddIsh("netdbExchangeStart", netdbExchangeStart, p, 30.0, 1); } @@ -1068,28 +1068,28 @@ neighborDumpNonPeers(StoreEntry * sentry) void dump_peer_options(StoreEntry * sentry, peer * p) { - if (EBIT_TEST(p->options, NEIGHBOR_PROXY_ONLY)) + if (p->options.proxy_only) storeAppendPrintf(sentry, " proxy-only"); - if (EBIT_TEST(p->options, NEIGHBOR_NO_QUERY)) + if (p->options.no_query) storeAppendPrintf(sentry, " no-query"); - if (EBIT_TEST(p->options, NEIGHBOR_NO_DIGEST)) + if (p->options.no_digest) storeAppendPrintf(sentry, " no-digest"); - if (EBIT_TEST(p->options, NEIGHBOR_DEFAULT_PARENT)) + if (p->options.default_parent) storeAppendPrintf(sentry, " default"); - if (EBIT_TEST(p->options, NEIGHBOR_ROUNDROBIN)) + if (p->options.roundrobin) storeAppendPrintf(sentry, " round-robin"); - if (EBIT_TEST(p->options, NEIGHBOR_MCAST_RESPONDER)) + if (p->options.mcast_responder) storeAppendPrintf(sentry, " multicast-responder"); - if (EBIT_TEST(p->options, NEIGHBOR_CLOSEST_ONLY)) + if (p->options.closest_only) storeAppendPrintf(sentry, " closest-only"); #if USE_HTCP - if (EBIT_TEST(p->options, NEIGHBOR_HTCP)) + if (p->options.htcp) storeAppendPrintf(sentry, " htcp"); #endif - if (EBIT_TEST(p->options, NEIGHBOR_NO_NETDB_EXCHANGE)) + if (p->options.no_netdb_exchange) storeAppendPrintf(sentry, " no-netdb-exchange"); #if DELAY_POOLS - if (EBIT_TEST(p->options, NEIGHBOR_NO_DELAY)) + if (p->options.no_delay) storeAppendPrintf(sentry, " no-delay"); #endif if (p->mcast.ttl > 0) @@ -1138,7 +1138,7 @@ dump_peers(StoreEntry * sentry, peer * peers) percent(e->stats.ignored_replies, e->stats.pings_acked)); storeAppendPrintf(sentry, "Histogram of PINGS ACKED:\n"); #if USE_HTCP - if (EBIT_TEST(e->options, NEIGHBOR_HTCP)) { + if (e->options.htcp) { storeAppendPrintf(sentry, "\tMisses\t%8d %3d%%\n", e->htcp.counts[0], percent(e->htcp.counts[0], e->stats.pings_acked)); diff --git a/src/peer_digest.cc b/src/peer_digest.cc index aee9fbfa75..74855f9cf6 100644 --- a/src/peer_digest.cc +++ b/src/peer_digest.cc @@ -1,6 +1,6 @@ /* - * $Id: peer_digest.cc,v 1.48 1998/09/14 21:28:07 wessels Exp $ + * $Id: peer_digest.cc,v 1.49 1998/09/14 21:58:52 wessels Exp $ * * DEBUG: section 72 Peer Digest Routines * AUTHOR: Alex Rousskov @@ -78,7 +78,7 @@ peerDigestInit(void *data) assert(p->digest.flags == (1 << PD_INIT_PENDING)); assert(!p->digest.cd); assert(SM_PAGE_SIZE == 4096); /* we use MEM_4K_BUF */ - if (EBIT_TEST(p->options, NEIGHBOR_NO_DIGEST)) { + if (p->options.no_digest) { peerDigestDisable(p); } else { cbdataLock(p); diff --git a/src/peer_select.cc b/src/peer_select.cc index 3af49ea12b..1a0a7cb82c 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -1,6 +1,6 @@ /* - * $Id: peer_select.cc,v 1.80 1998/09/14 21:28:08 wessels Exp $ + * $Id: peer_select.cc,v 1.81 1998/09/14 21:58:52 wessels Exp $ * * DEBUG: section 44 Peer Selection Algorithm * AUTHOR: Duane Wessels @@ -433,7 +433,7 @@ peerIcpParentMiss(peer * p, icp_common_t * header, ps_state * ps) } } /* if closest-only is set, then don't allow FIRST_PARENT_MISS */ - if (EBIT_TEST(p->options, NEIGHBOR_CLOSEST_ONLY)) + if (p->options.closest_only) return; /* set FIRST_MISS if there is no CLOSEST parent */ if (ps->closest_parent_miss.sin_addr.s_addr != any_addr.s_addr) @@ -526,7 +526,7 @@ peerHtcpParentMiss(peer * p, htcpReplyData * htcp, ps_state * ps) } } /* if closest-only is set, then don't allow FIRST_PARENT_MISS */ - if (EBIT_TEST(p->options, NEIGHBOR_CLOSEST_ONLY)) + if (p->options.closest_only) return; /* set FIRST_MISS if there is no CLOSEST parent */ if (ps->closest_parent_miss.sin_addr.s_addr != any_addr.s_addr) diff --git a/src/redirect.cc b/src/redirect.cc index 10a9c315de..d0785cd0b6 100644 --- a/src/redirect.cc +++ b/src/redirect.cc @@ -1,6 +1,6 @@ /* - * $Id: redirect.cc,v 1.65 1998/09/04 23:04:58 wessels Exp $ + * $Id: redirect.cc,v 1.66 1998/09/14 21:58:53 wessels Exp $ * * DEBUG: section 29 Redirector * AUTHOR: Duane Wessels @@ -46,7 +46,7 @@ typedef struct { typedef struct _redirector { int index; - int flags; + helper_flags flags; int fd; char *inbuf; unsigned int size; @@ -103,10 +103,13 @@ redirectHandleRead(int fd, void *data) if (len <= 0) { if (len < 0) debug(50, 1) ("redirectHandleRead: FD %d read: %s\n", fd, xstrerror()); - debug(29, EBIT_TEST(redirector->flags, HELPER_CLOSING) ? 5 : 1) + debug(29, redirector->flags.closing ? 5 : 1) ("FD %d: Connection from Redirector #%d is closed, disabling\n", fd, redirector->index + 1); - redirector->flags = 0; + redirector->flags.alive = 0; + redirector->flags.busy = 0; + redirector->flags.closing = 0; + redirector->flags.shutdown = 0; memFree(MEM_8K_BUF, redirector->inbuf); redirector->inbuf = NULL; comm_close(fd); @@ -146,7 +149,7 @@ redirectHandleRead(int fd, void *data) } redirectStateFree(r); redirector->redirectState = NULL; - EBIT_CLR(redirector->flags, HELPER_BUSY); + redirector->flags.busy = 0; redirector->offset = 0; n = ++RedirectStats.replies; RedirectStats.avg_svc_time = @@ -193,9 +196,9 @@ GetFirstAvailable(void) redirector_t *redirect = NULL; for (k = 0; k < NRedirectors; k++) { redirect = *(redirect_child_table + k); - if (EBIT_TEST(redirect->flags, HELPER_BUSY)) + if (redirect->flags.busy) continue; - if (!EBIT_TEST(redirect->flags, HELPER_ALIVE)) + if (!redirect->flags.alive) continue; return redirect; } @@ -222,7 +225,7 @@ redirectDispatch(redirector_t * redirect, redirectStateData * r) redirectStateFree(r); return; } - EBIT_SET(redirect->flags, HELPER_BUSY); + redirect->flags.busy = 1; redirect->redirectState = r; redirect->dispatch_time = current_time; if ((fqdn = fqdncache_gethostbyaddr(r->client_addr, 0)) == NULL) @@ -337,9 +340,9 @@ redirectOpenServers(void) &redirectsocket); if (x < 0) { debug(29, 1) ("WARNING: Cannot run '%s' process.\n", prg); - EBIT_CLR(redirect_child_table[k]->flags, HELPER_ALIVE); + redirect_child_table[k]->flags.alive = 0; } else { - EBIT_SET(redirect_child_table[k]->flags, HELPER_ALIVE); + redirect_child_table[k]->flags.alive = 1; redirect_child_table[k]->index = k; redirect_child_table[k]->fd = redirectsocket; redirect_child_table[k]->inbuf = memAllocate(MEM_8K_BUF); @@ -386,19 +389,19 @@ redirectShutdownServers(void *unused) } for (k = 0; k < NRedirectors; k++) { redirect = *(redirect_child_table + k); - if (!EBIT_TEST(redirect->flags, HELPER_ALIVE)) + if (!redirect->flags.alive) continue; - if (EBIT_TEST(redirect->flags, HELPER_CLOSING)) + if (redirect->flags.closing) continue; - if (EBIT_TEST(redirect->flags, HELPER_BUSY)) { + if (redirect->flags.busy) { na++; continue; } debug(29, 3) ("redirectShutdownServers: closing redirector #%d, FD %d\n", redirect->index + 1, redirect->fd); comm_close(redirect->fd); - EBIT_SET(redirect->flags, HELPER_CLOSING); - EBIT_SET(redirect->flags, HELPER_BUSY); + redirect->flags.closing = 1; + redirect->flags.busy = 1; } if (na) eventAdd("redirectShutdownServers", redirectShutdownServers, NULL, 1.0, 1); diff --git a/src/structs.h b/src/structs.h index 34071bba37..243a5fa238 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.221 1998/09/14 21:28:17 wessels Exp $ + * $Id: structs.h,v 1.222 1998/09/14 21:58:54 wessels Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -456,9 +456,16 @@ struct _dread_ctrl { void *client_data; }; +struct _helper_flags { + int alive:1; + int busy:1; + int closing:1; + int shutdown:1; +}; + struct _dnsserver_t { int id; - int flags; + helper_flags flags; int inpipe; int outpipe; time_t answer; @@ -988,7 +995,22 @@ struct _peer { domain_ping *pinglist; domain_type *typelist; acl_access *access; - int options; + struct { + int proxy_only:1; + int no_query:1; + int no_digest:1; + int default_parent:1; + int roundrobin:1; + int mcast_responder:1; + int closest_only:1; +#if USE_HTCP + int htcp:1; +#endif + int no_netdb_exchange:1; +#if DELAY_POOLS + int no_delay:1; +#endif + } options; int weight; struct { double avg_n_members; diff --git a/src/typedefs.h b/src/typedefs.h index e03bc95269..e24fb91b00 100644 --- a/src/typedefs.h +++ b/src/typedefs.h @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.74 1998/09/14 21:28:18 wessels Exp $ + * $Id: typedefs.h,v 1.75 1998/09/14 21:58:55 wessels Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -132,6 +132,7 @@ typedef struct _StoreEntry StoreEntry; typedef struct _SwapDir SwapDir; typedef struct _request_flags request_flags; typedef struct _store_flags store_flags; +typedef struct _helper_flags helper_flags; typedef struct _request_t request_t; typedef struct _AccessLogEntry AccessLogEntry; typedef struct _cachemgr_passwd cachemgr_passwd; -- 2.47.3