]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Turn flags in CachePeer class into proper bool type.
authorFrancesco Chemolli <kinkie@squid-cache.org>
Fri, 25 Jan 2013 16:01:16 +0000 (17:01 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Fri, 25 Jan 2013 16:01:16 +0000 (17:01 +0100)
src/CachePeer.h
src/cache_cf.cc
src/neighbors.cc

index 50cea94978a74178890447079dba34f7f142c671..ec00d3031e1aed1864de77598022be754376618f 100644 (file)
@@ -93,45 +93,45 @@ public:
     acl_access *access;
 
     struct {
-        unsigned int proxy_only:1;
-        unsigned int no_query:1;
-        unsigned int background_ping:1;
-        unsigned int no_digest:1;
-        unsigned int default_parent:1;
-        unsigned int roundrobin:1;
-        unsigned int weighted_roundrobin:1;
-        unsigned int mcast_responder:1;
-        unsigned int closest_only:1;
+        bool proxy_only;
+        bool no_query;
+        bool background_ping;
+        bool no_digest;
+        bool default_parent;
+        bool roundrobin;
+        bool weighted_roundrobin;
+        bool mcast_responder;
+        bool closest_only;
 #if USE_HTCP
-        unsigned int htcp:1;
-        unsigned int htcp_oldsquid:1;
-        unsigned int htcp_no_clr:1;
-        unsigned int htcp_no_purge_clr:1;
-        unsigned int htcp_only_clr:1;
-        unsigned int htcp_forward_clr:1;
+        bool htcp;
+        bool htcp_oldsquid;
+        bool htcp_no_clr;
+        bool htcp_no_purge_clr;
+        bool htcp_only_clr;
+        bool htcp_forward_clr;
 #endif
-        unsigned int no_netdb_exchange:1;
+        bool no_netdb_exchange;
 #if USE_DELAY_POOLS
-        unsigned int no_delay:1;
+        bool no_delay;
 #endif
-        unsigned int allow_miss:1;
-        unsigned int carp:1;
+        bool allow_miss;
+        bool carp;
         struct {
-            unsigned int set:1; //If false, whole url is to be used. Overrides others
-            unsigned int scheme:1;
-            unsigned int host:1;
-            unsigned int port:1;
-            unsigned int path:1;
-            unsigned int params:1;
+            bool set; //If false, whole url is to be used. Overrides others
+            bool scheme;
+            bool host;
+            bool port;
+            bool path;
+            bool params;
         } carp_key;
 #if USE_AUTH
-        unsigned int userhash:1;
+        bool userhash;
 #endif
-        unsigned int sourcehash:1;
-        unsigned int originserver:1;
-        unsigned int no_tproxy:1;
+        bool sourcehash;
+        bool originserver;
+        bool no_tproxy;
 #if PEER_MULTICAST_SIBLINGS
-        unsigned int mcast_siblings:1;
+        bool mcast_siblings;
 #endif
     } options;
 
@@ -146,8 +146,8 @@ public:
         int id;
 
         struct {
-            unsigned int count_event_pending:1;
-            unsigned int counting:1;
+            bool count_event_pending;
+            bool counting;
         } flags;
     } mcast;
 #if USE_CACHE_DIGESTS
index 2fb372ff23d53a5fb4ac72866e62ac97e6550d98..a543b10ba30a13626c6b2277ee6d0a1709b19806 100644 (file)
@@ -2107,8 +2107,8 @@ parse_peer(CachePeer ** head)
     p->type = parseNeighborType(token);
 
     if (p->type == PEER_MULTICAST) {
-        p->options.no_digest = 1;
-        p->options.no_netdb_exchange = 1;
+        p->options.no_digest = true;
+        p->options.no_netdb_exchange = true;
     }
 
     p->http_port = GetTcpService();
@@ -2121,27 +2121,27 @@ parse_peer(CachePeer ** head)
 
     while ((token = strtok(NULL, w_space))) {
         if (!strcasecmp(token, "proxy-only")) {
-            p->options.proxy_only = 1;
+            p->options.proxy_only = true;
         } else if (!strcasecmp(token, "no-query")) {
-            p->options.no_query = 1;
+            p->options.no_query = true;
         } else if (!strcasecmp(token, "background-ping")) {
-            p->options.background_ping = 1;
+            p->options.background_ping = true;
         } else if (!strcasecmp(token, "no-digest")) {
-            p->options.no_digest = 1;
+            p->options.no_digest = true;
         } else if (!strcasecmp(token, "no-tproxy")) {
-            p->options.no_tproxy = 1;
+            p->options.no_tproxy = true;
         } else if (!strcasecmp(token, "multicast-responder")) {
-            p->options.mcast_responder = 1;
+            p->options.mcast_responder = true;
 #if PEER_MULTICAST_SIBLINGS
         } else if (!strcasecmp(token, "multicast-siblings")) {
-            p->options.mcast_siblings = 1;
+            p->options.mcast_siblings = true;
 #endif
         } else if (!strncasecmp(token, "weight=", 7)) {
             p->weight = xatoi(token + 7);
         } else if (!strncasecmp(token, "basetime=", 9)) {
             p->basetime = xatoi(token + 9);
         } else if (!strcasecmp(token, "closest-only")) {
-            p->options.closest_only = 1;
+            p->options.closest_only = true;
         } else if (!strncasecmp(token, "ttl=", 4)) {
             p->mcast.ttl = xatoi(token + 4);
 
@@ -2151,17 +2151,17 @@ parse_peer(CachePeer ** head)
             if (p->mcast.ttl > 128)
                 p->mcast.ttl = 128;
         } else if (!strcasecmp(token, "default")) {
-            p->options.default_parent = 1;
+            p->options.default_parent = true;
         } else if (!strcasecmp(token, "round-robin")) {
-            p->options.roundrobin = 1;
+            p->options.roundrobin = true;
         } else if (!strcasecmp(token, "weighted-round-robin")) {
-            p->options.weighted_roundrobin = 1;
+            p->options.weighted_roundrobin = true;
 #if USE_HTCP
         } else if (!strcasecmp(token, "htcp")) {
-            p->options.htcp = 1;
+            p->options.htcp = true;
         } else if (!strncasecmp(token, "htcp=", 5) || !strncasecmp(token, "htcp-", 5)) {
             /* Note: The htcp- form is deprecated, replaced by htcp= */
-            p->options.htcp = 1;
+            p->options.htcp = true;
             char *tmp = xstrdup(token+5);
             char *mode, *nextmode;
             for (mode = nextmode = tmp; mode; mode = nextmode) {
@@ -2173,17 +2173,17 @@ parse_peer(CachePeer ** head)
                 if (!strcasecmp(mode, "no-clr")) {
                     if (p->options.htcp_only_clr)
                         fatalf("parse_peer: can't set htcp-no-clr and htcp-only-clr simultaneously");
-                    p->options.htcp_no_clr = 1;
+                    p->options.htcp_no_clr = true;
                 } else if (!strcasecmp(mode, "no-purge-clr")) {
-                    p->options.htcp_no_purge_clr = 1;
+                    p->options.htcp_no_purge_clr = true;
                 } else if (!strcasecmp(mode, "only-clr")) {
                     if (p->options.htcp_no_clr)
                         fatalf("parse_peer: can't set htcp no-clr and only-clr simultaneously");
-                    p->options.htcp_only_clr = 1;
+                    p->options.htcp_only_clr = true;
                 } else if (!strcasecmp(mode, "forward-clr")) {
-                    p->options.htcp_forward_clr = 1;
+                    p->options.htcp_forward_clr = true;
                 } else if (!strcasecmp(mode, "oldsquid")) {
-                    p->options.htcp_oldsquid = 1;
+                    p->options.htcp_oldsquid = true;
                 } else {
                     fatalf("invalid HTCP mode '%s'", mode);
                 }
@@ -2191,31 +2191,31 @@ parse_peer(CachePeer ** head)
             safe_free(tmp);
 #endif
         } else if (!strcasecmp(token, "no-netdb-exchange")) {
-            p->options.no_netdb_exchange = 1;
+            p->options.no_netdb_exchange = true;
 
         } else if (!strcasecmp(token, "carp")) {
             if (p->type != PEER_PARENT)
                 fatalf("parse_peer: non-parent carp peer %s/%d\n", p->host, p->http_port);
 
-            p->options.carp = 1;
+            p->options.carp = true;
         } else if (!strncasecmp(token, "carp-key=", 9)) {
-            if (p->options.carp != 1)
+            if (p->options.carp != true)
                 fatalf("parse_peer: carp-key specified on non-carp peer %s/%d\n", p->host, p->http_port);
-            p->options.carp_key.set=1;
+            p->options.carp_key.set = true;
             char *nextkey=token+strlen("carp-key="), *key=nextkey;
             for (; key; key = nextkey) {
                 nextkey=strchr(key,',');
                 if (nextkey) ++nextkey; // skip the comma, any
                 if (0==strncasecmp(key,"scheme",6)) {
-                    p->options.carp_key.scheme=1;
+                    p->options.carp_key.scheme = true;
                 } else if (0==strncasecmp(key,"host",4)) {
-                    p->options.carp_key.host=1;
+                    p->options.carp_key.host = true;
                 } else if (0==strncasecmp(key,"port",4)) {
-                    p->options.carp_key.port=1;
+                    p->options.carp_key.port = true;
                 } else if (0==strncasecmp(key,"path",4)) {
-                    p->options.carp_key.path=1;
+                    p->options.carp_key.path = true;
                 } else if (0==strncasecmp(key,"params",6)) {
-                    p->options.carp_key.params=1;
+                    p->options.carp_key.params = true;
                 } else {
                     fatalf("invalid carp-key '%s'",key);
                 }
@@ -2225,7 +2225,7 @@ parse_peer(CachePeer ** head)
             if (p->type != PEER_PARENT)
                 fatalf("parse_peer: non-parent userhash peer %s/%d\n", p->host, p->http_port);
 
-            p->options.userhash = 1;
+            p->options.userhash = true;
 #else
             fatalf("parse_peer: userhash requires authentication. peer %s/%d\n", p->host, p->http_port);
 #endif
@@ -2233,11 +2233,11 @@ parse_peer(CachePeer ** head)
             if (p->type != PEER_PARENT)
                 fatalf("parse_peer: non-parent sourcehash peer %s/%d\n", p->host, p->http_port);
 
-            p->options.sourcehash = 1;
+            p->options.sourcehash = true;
 
         } else if (!strcasecmp(token, "no-delay")) {
 #if USE_DELAY_POOLS
-            p->options.no_delay = 1;
+            p->options.no_delay = true;
 #else
             debugs(0, DBG_CRITICAL, "WARNING: cache_peer option 'no-delay' requires --enable-delay-pools");
 #endif
@@ -2254,11 +2254,11 @@ parse_peer(CachePeer ** head)
 #endif
 
         } else if (!strcasecmp(token, "allow-miss")) {
-            p->options.allow_miss = 1;
+            p->options.allow_miss = true;
         } else if (!strncasecmp(token, "max-conn=", 9)) {
             p->max_conn = xatoi(token + 9);
         } else if (!strcasecmp(token, "originserver")) {
-            p->options.originserver = 1;
+            p->options.originserver = true;
         } else if (!strncasecmp(token, "name=", 5)) {
             safe_free(p->name);
 
index 041ae6630952ec58c81623142c7b5bebb2f450fe..a9586954318c142e4d1fd4b1c745dcff446169c5 100644 (file)
@@ -1360,7 +1360,7 @@ peerCountMcastPeersSchedule(CachePeer * p, time_t when)
              p,
              (double) when, 1);
 
-    p->mcast.flags.count_event_pending = 1;
+    p->mcast.flags.count_event_pending = true;
 }
 
 static void
@@ -1374,7 +1374,7 @@ peerCountMcastPeersStart(void *data)
     int reqnum;
     LOCAL_ARRAY(char, url, MAX_URL);
     assert(p->type == PEER_MULTICAST);
-    p->mcast.flags.count_event_pending = 0;
+    p->mcast.flags.count_event_pending = false;
     snprintf(url, MAX_URL, "http://");
     p->in_addr.ToURL(url+7, MAX_URL -8 );
     strcat(url, "/");
@@ -1401,7 +1401,7 @@ peerCountMcastPeersStart(void *data)
              peerCountMcastPeersDone,
              psstate,
              Config.Timeout.mcast_icp_query / 1000.0, 1);
-    p->mcast.flags.counting = 1;
+    p->mcast.flags.counting = true;
     peerCountMcastPeersSchedule(p, MCAST_COUNT_RATE);
 }
 
@@ -1413,7 +1413,7 @@ peerCountMcastPeersDone(void *data)
 
     if (cbdataReferenceValid(psstate->callback_data)) {
         CachePeer *p = (CachePeer *)psstate->callback_data;
-        p->mcast.flags.counting = 0;
+        p->mcast.flags.counting = false;
         p->mcast.avg_n_members = Math::doubleAverage(p->mcast.avg_n_members, (double) psstate->ping.n_recv, ++p->mcast.n_times_counted, 10);
         debugs(15, DBG_IMPORTANT, "Group " << p->host  << ": " << psstate->ping.n_recv  <<
                " replies, "<< std::setw(4)<< std::setprecision(2) <<