]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
more EBIT replacements
authorwessels <>
Tue, 15 Sep 1998 04:17:56 +0000 (04:17 +0000)
committerwessels <>
Tue, 15 Sep 1998 04:17:56 +0000 (04:17 +0000)
src/defines.h
src/enums.h
src/errorpage.cc
src/http.cc
src/neighbors.cc
src/peer_digest.cc
src/protos.h
src/stat.cc
src/structs.h
src/typedefs.h
src/urn.cc

index 4e24e768dfd34107a53dda711f3e6d988d0bc4c4..6ac6b86bbb54dcd275bc13c6bbd7f963596e4bb9 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: defines.h,v 1.65 1998/08/25 04:11:36 wessels Exp $
+ * $Id: defines.h,v 1.66 1998/09/14 22:18:45 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
 #define PEER_MAX_ADDRESSES 10
 #define RTT_AV_FACTOR      50
 
-/* flags for peer->mcast.flags */
-#define PEER_COUNT_EVENT_PENDING 1
-#define PEER_COUNTING           2
-
 #define PEER_DEAD 0
 #define PEER_ALIVE 1
 
index 2f054933ce1bf4eafc80ea8055a01591bd17529f..43acd75dc6b9ce57ec61d601379b1ec844c2141b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: enums.h,v 1.128 1998/09/14 21:58:47 wessels Exp $
+ * $Id: enums.h,v 1.129 1998/09/14 22:17:56 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -428,19 +428,6 @@ typedef enum {
     HTTP_INVALID_HEADER = 600  /* Squid header parsing error */
 } http_status;
 
-typedef enum {
-    PD_INITED,                 /* initialized */
-    PD_USABLE,                 /* ready to use */
-    PD_REQUESTED,              /* we are in the process of receiving a [fresh] digest */
-    PD_DISABLED,               /* do not use/validate the digest */
-    PD_INIT_PENDING
-} peer_cd_t;
-
-enum {
-    HTTP_PROXYING,
-    HTTP_KEEPALIVE
-};
-
 enum {
     ERR_FLAG_CBDATA
 };
index 863758694ca0ca054d124bfc3237a75e8c4b06f0..081729d24335d909819147102e6f1027ac160359 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: errorpage.cc,v 1.141 1998/08/14 19:25:18 wessels Exp $
+ * $Id: errorpage.cc,v 1.142 1998/09/14 22:17:57 wessels Exp $
  *
  * DEBUG: section 4     Error Generation
  * AUTHOR: Duane Wessels
@@ -296,7 +296,7 @@ errorSend(int fd, ErrorState * err)
     if (err->request)
        err->request->err_type = err->type;
     /* moved in front of errorBuildBuf @?@ */
-    EBIT_SET(err->flags, ERR_FLAG_CBDATA);
+    err->flags.flag_cbdata = 1;
     cbdataAdd(err, MEM_NONE);
     rep = errorBuildReply(err);
     comm_write_mbuf(fd, httpReplyPack(rep), errorSendComplete, err);
@@ -335,7 +335,7 @@ errorStateFree(ErrorState * err)
     safe_free(err->host);
     safe_free(err->dnsserver_msg);
     safe_free(err->request_hdrs);
-    if (EBIT_TEST(err->flags, ERR_FLAG_CBDATA))
+    if (err->flags.flag_cbdata)
        cbdataFree(err);
     else
        safe_free(err);
index f216be4a522c3a126a57fa1bf125d8aa0ad7a802..529f33cd5e1c276ebd109e32cb408d52befcf3e7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.cc,v 1.318 1998/09/14 21:58:49 wessels Exp $
+ * $Id: http.cc,v 1.319 1998/09/14 22:17:57 wessels Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -323,7 +323,7 @@ httpProcessReplyHeader(HttpStateData * httpState, const char *buf, int size)
            else if (EBIT_TEST(reply->cache_control->mask, CC_MUST_REVALIDATE))
                entry->flags.entry_revalidate = 1;
        }
-       if (EBIT_TEST(httpState->flags, HTTP_KEEPALIVE))
+       if (httpState->flags.keepalive)
            if (httpState->peer)
                httpState->peer->stats.n_keepalives_sent++;
        if (reply->keep_alive)
@@ -344,7 +344,7 @@ httpPconnTransferDone(HttpStateData * httpState)
      * If we didn't send a keep-alive request header, then this
      * can not be a persistent connection.
      */
-    if (!EBIT_TEST(httpState->flags, HTTP_KEEPALIVE))
+    if (!httpState->flags.keepalive)
        return 0;
     /*
      * What does the reply have to say about keep-alive?
@@ -563,7 +563,7 @@ httpBuildRequestHeader(request_t * request,
     StoreEntry * entry,
     HttpHeader * hdr_out,
     int cfd,
-    int flags)
+    http_state_flags flags)
 {
     /* building buffer for complex strings */
 #define BBUF_SZ (MAX_URL+32)
@@ -678,8 +678,8 @@ httpBuildRequestHeader(request_t * request,
        httpHdrCcDestroy(cc);
     }
     /* maybe append Connection: keep-alive */
-    if (EBIT_TEST(flags, HTTP_KEEPALIVE)) {
-       if (EBIT_TEST(flags, HTTP_PROXYING)) {
+    if (flags.keepalive) {
+       if (flags.proxying) {
            httpHeaderPutStr(hdr_out, HDR_PROXY_CONNECTION, "keep-alive");
        } else {
            httpHeaderPutStr(hdr_out, HDR_CONNECTION, "keep-alive");
@@ -696,7 +696,7 @@ httpBuildRequestPrefix(request_t * request,
     StoreEntry * entry,
     MemBuf * mb,
     int cfd,
-    int flags)
+    http_state_flags flags)
 {
     const int offset = mb->size;
     memBufPrintf(mb, "%s %s HTTP/1.0\r\n",
@@ -744,16 +744,16 @@ httpSendRequest(int fd, void *data)
        cfd = entry->mem_obj->fd;
     assert(-1 == cfd || FD_SOCKET == fd_table[cfd].type);
     if (p != NULL)
-       EBIT_SET(httpState->flags, HTTP_PROXYING);
+       httpState->flags.proxying = 1;
     /*
      * Is keep-alive okay for all request methods?
      */
     if (p == NULL)
-       EBIT_SET(httpState->flags, HTTP_KEEPALIVE);
+       httpState->flags.keepalive = 1;
     else if (p->stats.n_keepalives_sent < 10)
-       EBIT_SET(httpState->flags, HTTP_KEEPALIVE);
+       httpState->flags.keepalive = 1;
     else if ((double) p->stats.n_keepalives_recv / (double) p->stats.n_keepalives_sent > 0.50)
-       EBIT_SET(httpState->flags, HTTP_KEEPALIVE);
+       httpState->flags.keepalive = 1;
     memBufDefInit(&mb);
     httpBuildRequestPrefix(req,
        httpState->orig_request,
index b7bddd252910217c7a9decf946f1b074385cf2ce..11d09381fc318807add8b0f46e6dbe855b76ebad 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: neighbors.cc,v 1.247 1998/09/14 21:58:51 wessels Exp $
+ * $Id: neighbors.cc,v 1.248 1998/09/14 22:17:59 wessels Exp $
  *
  * DEBUG: section 15    Neighbor Routines
  * AUTHOR: Harvest Derived
@@ -490,19 +490,19 @@ peerDigestLookup(peer * p, request_t * request, StoreEntry * entry)
     assert(request);
     debug(15, 5) ("peerDigestLookup: peer %s\n", p->host);
     /* does the peeer have a valid digest? */
-    if (EBIT_TEST(p->digest.flags, PD_DISABLED)) {
+    if (p->digest.flags.disabled) {
        debug(15, 5) ("peerDigestLookup: Disabled!\n");
        return LOOKUP_NONE;
     } else if (!peerAllowedToUse(p, request)) {
        debug(15, 5) ("peerDigestLookup: !peerAllowedToUse()\n");
        return LOOKUP_NONE;
-    } else if (EBIT_TEST(p->digest.flags, PD_USABLE)) {
+    } else if (p->digest.flags.usable) {
        debug(15, 5) ("peerDigestLookup: Usable!\n");
        /* fall through; put here to have common case on top */ ;
-    } else if (!EBIT_TEST(p->digest.flags, PD_INITED)) {
+    } else if (!p->digest.flags.inited) {
        debug(15, 5) ("peerDigestLookup: !initialized\n");
-       if (!EBIT_TEST(p->digest.flags, PD_INIT_PENDING)) {
-           EBIT_SET(p->digest.flags, PD_INIT_PENDING);
+       if (!p->digest.flags.init_pending) {
+           p->digest.flags.init_pending = 1;
            eventAdd("peerDigestInit", peerDigestInit, p, 0.0, 1);
        }
        return LOOKUP_NONE;
@@ -960,13 +960,13 @@ peerCheckConnectStart(peer * p)
 static void
 peerCountMcastPeersSchedule(peer * p, time_t when)
 {
-    if (p->mcast.flags & PEER_COUNT_EVENT_PENDING)
+    if (p->mcast.flags.count_event_pending)
        return;
     eventAdd("peerCountMcastPeersStart",
        peerCountMcastPeersStart,
        p,
        (double) when, 1);
-    p->mcast.flags |= PEER_COUNT_EVENT_PENDING;
+    p->mcast.flags.count_event_pending = 1;
 }
 
 static void
@@ -980,7 +980,7 @@ peerCountMcastPeersStart(void *data)
     int reqnum;
     LOCAL_ARRAY(char, url, MAX_URL);
     assert(p->type == PEER_MULTICAST);
-    p->mcast.flags &= ~PEER_COUNT_EVENT_PENDING;
+    p->mcast.flags.count_event_pending = 0;
     snprintf(url, MAX_URL, "http://%s/", inet_ntoa(p->in_addr.sin_addr));
     fake = storeCreateEntry(url, url, null_request_flags, METHOD_GET);
     psstate->request = requestLink(urlParse(METHOD_GET, url));
@@ -1009,7 +1009,7 @@ peerCountMcastPeersStart(void *data)
        peerCountMcastPeersDone,
        psstate,
        (double) Config.Timeout.mcast_icp_query, 1);
-    p->mcast.flags |= PEER_COUNTING;
+    p->mcast.flags.counting = 1;
     peerCountMcastPeersSchedule(p, MCAST_COUNT_RATE);
 }
 
@@ -1019,7 +1019,7 @@ peerCountMcastPeersDone(void *data)
     ps_state *psstate = data;
     peer *p = psstate->callback_data;
     StoreEntry *fake = psstate->entry;
-    p->mcast.flags &= ~PEER_COUNTING;
+    p->mcast.flags.counting = 0;
     p->mcast.avg_n_members = doubleAverage(p->mcast.avg_n_members,
        (double) psstate->ping.n_recv,
        ++p->mcast.n_times_counted,
index 74855f9cf60cd8eab9605b555d64ffd51c858489..b6a3f6fd1197937518043a701a0cac3bd656a13e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: peer_digest.cc,v 1.49 1998/09/14 21:58:52 wessels Exp $
+ * $Id: peer_digest.cc,v 1.50 1998/09/14 22:17:59 wessels Exp $
  *
  * DEBUG: section 72    Peer Digest Routines
  * AUTHOR: Alex Rousskov
@@ -84,8 +84,8 @@ peerDigestInit(void *data)
        cbdataLock(p);
        peerDigestValidate(p);
     }
-    EBIT_SET(p->digest.flags, PD_INITED);
-    EBIT_CLR(p->digest.flags, PD_INIT_PENDING);
+    p->digest.flags.inited = 1;
+    p->digest.flags.init_pending = 0;
 }
 
 /* no pending events or requests should exist when you call this */
@@ -95,7 +95,7 @@ peerDigestClean(peer * p)
     if (!cbdataValid(p))
        debug(72, 2) ("peerDigest: note: peer '%s' was reset or deleted\n",
            p->host ? p->host : "<null>");
-    assert(!EBIT_TEST(p->digest.flags, PD_REQUESTED));
+    assert(!p->digest.flags.requested);
     peerDigestDisable(p);
     cbdataUnlock(p);
 }
@@ -136,7 +136,7 @@ peerDigestDelay(peer * p, int disable, time_t delay)
 {
     assert(p);
     if (disable) {
-       EBIT_SET(p->digest.flags, PD_DISABLED);
+       p->digest.flags.disabled = 1;
        p->digest.last_dis_delay = delay;
     }
     if (delay >= 0) {
@@ -151,7 +151,7 @@ peerDigestDelay(peer * p, int disable, time_t delay)
        debug(72, 2) ("peerDigestDisable: disabling peer %s for good\n",
            p->host ? p->host : "<null>");
        /* just in case, will not need it anymore */
-       EBIT_CLR(p->digest.flags, PD_USABLE);
+       p->digest.flags.usable = 0;
     }
 }
 
@@ -170,7 +170,7 @@ peerDigestValidate(void *data)
        return;
     }
     debug(72, 3) ("current GMT time: %s\n", mkrfc1123(squid_curtime));
-    assert(!EBIT_TEST(p->digest.flags, PD_REQUESTED));
+    assert(!p->digest.flags.requested);
     debug(72, 3) ("peerDigestValidate: %s was %s disabled\n",
        p->host, p->digest.last_dis_delay ? "" : "not");
     if (1 /* p->digest.cd */ ) {
@@ -200,7 +200,7 @@ peerDigestValidate(void *data)
        req_time = p->digest.last_req_timestamp + PeerDigestRequestMinGap;
     }
     /* at start, do not request too often from all peers */
-    if (!EBIT_TEST(p->digest.flags, PD_INITED) &&
+    if (!p->digest.flags.inited &&
        req_time - global_last_req_timestamp < GlobalDigestRequestMinGap) {
        if (do_request) {
            debug(72, 2) ("peerDigestValidate: %s, avoiding too close requests (%d secs).\n",
@@ -240,7 +240,7 @@ peerDigestRequest(peer * p)
     request_t *req;
     DigestFetchState *fetch = NULL;
     assert(p);
-    EBIT_SET(p->digest.flags, PD_REQUESTED);
+    p->digest.flags.requested = 1;
     /* compute future request components */
     url = internalRemoteUri(p->host, p->http_port, "/squid-internal-periodic/", StoreDigestUrlPath);
     key = storeKeyPublic(url, METHOD_GET);
@@ -533,7 +533,7 @@ peerDigestFetchFinish(DigestFetchState * fetch, char *buf, const char *err_msg)
            peer->digest.cd = NULL;
        }
        /* disable for a while */
-       EBIT_CLR(peer->digest.flags, PD_USABLE);
+       peer->digest.flags.usable = 0;
        peerDigestDelay(peer, 1,
            max_delay(
                peerDigestExpiresDelay(peer, fetch->entry),
@@ -547,8 +547,8 @@ peerDigestFetchFinish(DigestFetchState * fetch, char *buf, const char *err_msg)
        } else {
            debug(72, 2) ("received valid digest from %s\n", peer->host);
        }
-       EBIT_SET(peer->digest.flags, PD_USABLE);
-       EBIT_CLR(peer->digest.flags, PD_DISABLED);
+       peer->digest.flags.usable = 1;
+       peer->digest.flags.disabled = 0;
        peer->digest.last_dis_delay = 0;
        peerDigestDelay(peer, 0,
            max_delay(peerDigestExpiresDelay(peer, fetch->entry), 0));
@@ -578,7 +578,7 @@ peerDigestFetchFinish(DigestFetchState * fetch, char *buf, const char *err_msg)
     /* set it here and in peerDigestRequest to protect against long downloads */
     peer->digest.last_req_timestamp = squid_curtime;
     peer->digest.last_fetch_resp_time = fetch_resp_time;
-    EBIT_CLR(peer->digest.flags, PD_REQUESTED);
+    peer->digest.flags.requested = 0;
     debug(72, 2) ("peerDigestFetchFinish: %s done; took: %d secs; expires: %s\n",
        peer->host, fetch_resp_time, mkrfc1123(expires));
 }
index f2032d31850341ee05e0ddd99d66764a0f12859e..aa21750c4d3f458a803636953c9b0a8df41e78b7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.263 1998/09/14 21:28:09 wessels Exp $
+ * $Id: protos.h,v 1.264 1998/09/14 22:18:00 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -261,11 +261,11 @@ extern size_t httpBuildRequestPrefix(request_t * request,
     StoreEntry * entry,
     MemBuf * mb,
     int cfd,
-    int flags);
+    http_state_flags);
 extern void httpAnonInitModule();
 extern int httpAnonHdrAllowed(http_hdr_type hdr_id);
 extern int httpAnonHdrDenied(http_hdr_type hdr_id);
-extern void httpBuildRequestHeader(request_t *, request_t *, StoreEntry *, HttpHeader *, int, int);
+extern void httpBuildRequestHeader(request_t *, request_t *, StoreEntry *, HttpHeader *, int, http_state_flags);
 
 /* ETag */
 extern int etagParseInit(ETag * etag, const char *str);
index 45c435574c95c29e194fdb716d123f5129721986..617b0f6ac7d424ee9f01d371a970f177fd94da4c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: stat.cc,v 1.287 1998/09/14 21:28:10 wessels Exp $
+ * $Id: stat.cc,v 1.288 1998/09/14 22:18:01 wessels Exp $
  *
  * DEBUG: section 18    Cache Manager Statistics
  * AUTHOR: Harvest Derived
@@ -1126,10 +1126,10 @@ statPeerSelect(StoreEntry * sentry)
        storeAppendPrintf(sentry, "peer.local_memory = %d\n",
            peer->digest.cd ? peer->digest.cd->mask_size / 1024 : 0);
        storeAppendPrintf(sentry, "digest state: inited: %d, disabled: %d usable: %d requested: %d\n",
-           0 < EBIT_TEST(peer->digest.flags, PD_INITED),
-           0 < EBIT_TEST(peer->digest.flags, PD_DISABLED),
-           0 < EBIT_TEST(peer->digest.flags, PD_USABLE),
-           0 < EBIT_TEST(peer->digest.flags, PD_REQUESTED)
+           0 < peer->digest.flags.inited,
+           0 < peer->digest.flags.disabled,
+           0 < peer->digest.flags.usable,
+           0 < peer->digest.flags.requested
            );
        if (peer->digest.cd)
            cacheDigestReport(peer->digest.cd, peer->host, sentry);
index 243a5fa238cdbae72652e7d8a5cd9aba51c05eac..d89fd856561974794a5a87f6959194c2769cbf2e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.222 1998/09/14 21:58:54 wessels Exp $
+ * $Id: structs.h,v 1.223 1998/09/14 22:18:02 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -699,6 +699,10 @@ struct _HttpReply {
     HttpBody body;             /* for small constant memory-resident text bodies only */
 };
 
+struct _http_state_flags {
+       int proxying:1;
+       int keepalive:1;
+};
 
 struct _HttpStateData {
     StoreEntry *entry;
@@ -709,7 +713,7 @@ struct _HttpStateData {
     int eof;                   /* reached end-of-object? */
     request_t *orig_request;
     int fd;
-    int flags;
+    http_state_flags flags;
     FwdState *fwdState;
 };
 
@@ -949,7 +953,13 @@ struct _cd_guess_stats {
 
 struct _PeerDigest {
     CacheDigest *cd;
-    int flags;                 /* PD_ */
+    struct {
+       int inited:1;           /* initialized */
+       int usable:1;           /* ready to use */
+       int requested:1;        /* in process of receiving [fresh] digest */
+       int disabled:1;         /* do not use/validate the digest */
+       int init_pending:1;
+    } flags;
     time_t last_fetch_resp_time;
     time_t last_req_timestamp;
     time_t last_dis_delay;     /* last disability delay */
@@ -1018,7 +1028,10 @@ struct _peer {
        int n_replies_expected;
        int ttl;
        int id;
-       int flags;
+       struct {
+               int count_event_pending:1;
+               int counting:1;
+       }
     } mcast;
     PeerDigest digest;
     int tcp_up;                        /* 0 if a connect() fails */
@@ -1347,7 +1360,9 @@ struct _ErrorState {
     char *redirect_url;
     ERCB *callback;
     void *callback_data;
-    int flags;
+    struct {
+       int flag_cbdata:1;
+    } flags;
     struct {
        char *request;
        char *reply;
index e24fb91b00bcbae6b00aace2851b0aa925119a44..f1f4b1cff55d072a4f4e662d499f51774eb95fb1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: typedefs.h,v 1.75 1998/09/14 21:58:55 wessels Exp $
+ * $Id: typedefs.h,v 1.76 1998/09/14 22:18:03 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -133,6 +133,7 @@ typedef struct _SwapDir SwapDir;
 typedef struct _request_flags request_flags;
 typedef struct _store_flags store_flags;
 typedef struct _helper_flags helper_flags;
+typedef struct _http_state_flags http_state_flags;
 typedef struct _request_t request_t;
 typedef struct _AccessLogEntry AccessLogEntry;
 typedef struct _cachemgr_passwd cachemgr_passwd;
index e6467fd371c5a461aadf060b5d6a13c74228be38..6a6d95a1867528c112790c303eb6c2fb90cbe992 100644 (file)
@@ -1,7 +1,7 @@
 
 /*
  *
- * $Id: urn.cc,v 1.44 1998/09/01 23:31:25 wessels Exp $
+ * $Id: urn.cc,v 1.46 1998/09/14 22:18:46 wessels Exp $
  *
  * DEBUG: section 52    URN Parsing
  * AUTHOR: Kostas Anagnostakis
 
 #include "squid.h"
 
-enum {
-    URN_FORCE_MENU
-};
-
 typedef struct {
     StoreEntry *entry;
     StoreEntry *urlres_e;
     request_t *request;
     request_t *urlres_r;
-    int flags;
+    struct {
+       int force_menu:1;
+    } flags;
 } UrnState;
 
 typedef struct {
@@ -116,7 +114,7 @@ urnStart(request_t * r, StoreEntry * e)
     storeLockObject(urnState->entry);
     if (strncasecmp(strBuf(r->urlpath), "menu.", 5) == 0) {
        char *new_path = xstrdup(strBuf(r->urlpath) + 5);
-       EBIT_SET(urnState->flags, URN_FORCE_MENU);
+       urnState->flags.force_menu = 1;
        stringReset(&r->urlpath, new_path);
        xfree(new_path);
     }
@@ -282,7 +280,7 @@ urnHandleReply(void *data, char *buf, ssize_t size)
     httpReplyReset(rep);
     httpReplySetHeaders(rep, 1.0, HTTP_MOVED_TEMPORARILY, NULL,
        "text/html", mb.size, 0, squid_curtime);
-    if (EBIT_TEST(urnState->flags, URN_FORCE_MENU)) {
+    if (urnState->flags.force_menu) {
        debug(51, 3) ("urnHandleReply: forcing menu\n");
     } else if (min_u) {
        httpHeaderPutStr(&rep->header, HDR_LOCATION, min_u->url);