From: wessels <> Date: Fri, 21 Aug 1998 09:15:14 +0000 (+0000) Subject: Trade request_t->flags enums (REQ_*) request_flags int:1 structure X-Git-Tag: SQUID_3_0_PRE1~2826 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=92695e5e7715b646aceb115bf3cbc3a19ab105e4;p=thirdparty%2Fsquid.git Trade request_t->flags enums (REQ_*) request_flags int:1 structure --- diff --git a/src/acl.cc b/src/acl.cc index 69a946b572..52d7e1f3c5 100644 --- a/src/acl.cc +++ b/src/acl.cc @@ -1,6 +1,6 @@ /* - * $Id: acl.cc,v 1.180 1998/08/20 22:29:53 wessels Exp $ + * $Id: acl.cc,v 1.181 1998/08/21 03:15:14 wessels Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -1222,7 +1222,7 @@ aclMatchAcl(acl * acl, aclCheck_t * checklist) } else if (k == 1) { /* register that we used the proxy authentication header */ checklist->state[ACL_PROXY_AUTH] = ACL_PROXY_AUTH_USED; - EBIT_SET(r->flags, REQ_USED_PROXY_AUTH); + r->flags.used_proxy_auth = 1; return 1; } else if (k == -1) { /* register that we need to check the password */ diff --git a/src/client_side.cc b/src/client_side.cc index aeb44803fc..8b5e4e1ee8 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.384 1998/08/20 22:45:46 wessels Exp $ + * $Id: client_side.cc,v 1.385 1998/08/21 03:15:15 wessels Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -143,7 +143,7 @@ clientConstructProxyAuthReply(clientHttpRequest * http) } StoreEntry * -clientCreateStoreEntry(clientHttpRequest * h, method_t m, int flags) +clientCreateStoreEntry(clientHttpRequest * h, method_t m, request_flags flags) { StoreEntry *e; /* @@ -178,7 +178,7 @@ clientAccessCheckDone(int answer, void *data) redirectStart(http, clientRedirectDone, http); } else if (answer == ACCESS_REQ_PROXY_AUTH) { http->log_type = LOG_TCP_DENIED; - http->entry = clientCreateStoreEntry(http, http->request->method, 0); + http->entry = clientCreateStoreEntry(http, http->request->method, null_request_flags); /* create appropriate response */ http->entry->mem_obj->reply = clientConstructProxyAuthReply(http); httpReplySwapOut(http->entry->mem_obj->reply, http->entry); @@ -188,7 +188,7 @@ clientAccessCheckDone(int answer, void *data) debug(33, 5) ("AclMatchedName = %s\n", AclMatchedName ? AclMatchedName : ""); http->log_type = LOG_TCP_DENIED; - http->entry = clientCreateStoreEntry(http, http->request->method, 0); + http->entry = clientCreateStoreEntry(http, http->request->method, null_request_flags); page_id = aclGetDenyInfoPage(&Config.denyInfoList, AclMatchedName); /* NOTE: don't use HTTP_UNAUTHORIZED because then the * stupid browser wants us to authenticate */ @@ -219,7 +219,7 @@ clientRedirectDone(void *data, char *result) new_request->http_ver = old_request->http_ver; httpHeaderAppend(&new_request->header, &old_request->header); new_request->client_addr = old_request->client_addr; - EBIT_SET(new_request->flags, REQ_REDIRECTED); + new_request->flags.redirected = 1; if (old_request->body) { new_request->body = xmalloc(old_request->body_sz); xmemcpy(new_request->body, old_request->body, old_request->body_sz); @@ -250,7 +250,7 @@ clientProcessExpired(void *data) clientProcessOnlyIfCachedMiss(http); return; } - EBIT_SET(http->request->flags, REQ_REFRESH); + http->request->flags.refresh = 1; http->old_entry = http->entry; entry = storeCreateEntry(url, http->log_uri, @@ -298,7 +298,7 @@ clientGetsOldEntry(StoreEntry * new_entry, StoreEntry * old_entry, request_t * r } /* If the client did not send IMS in the request, then it * must get the old object, not this "Not Modified" reply */ - if (!EBIT_TEST(request->flags, REQ_IMS)) { + if (!request->flags.ims) { debug(33, 5) ("clientGetsOldEntry: YES, no client IMS\n"); return 1; } @@ -457,7 +457,7 @@ clientPurgeRequest(clientHttpRequest * http) err = errorCon(ERR_ACCESS_DENIED, HTTP_FORBIDDEN); err->request = requestLink(http->request); err->src_addr = http->conn->peer.sin_addr; - http->entry = clientCreateStoreEntry(http, http->request->method, 0); + http->entry = clientCreateStoreEntry(http, http->request->method, null_request_flags); errorAppendEntry(http->entry, err); return; } @@ -475,7 +475,7 @@ clientPurgeRequest(clientHttpRequest * http) * Make a new entry to hold the reply to be written * to the client. */ - http->entry = clientCreateStoreEntry(http, http->request->method, 0); + http->entry = clientCreateStoreEntry(http, http->request->method, null_request_flags); httpReplyReset(r = http->entry->mem_obj->reply); httpReplySetHeaders(r, 1.0, http->http_code, NULL, NULL, 0, 0, -1); httpReplySwapOut(r, http->entry); @@ -676,16 +676,16 @@ clientInterpretRequestHeaders(clientHttpRequest * http) request->imslen = -1; request->ims = httpHeaderGetTime(req_hdr, HDR_IF_MODIFIED_SINCE); if (request->ims > 0) - EBIT_SET(request->flags, REQ_IMS); + request->flags.ims = 1; if (httpHeaderHas(req_hdr, HDR_PRAGMA)) { String s = httpHeaderGetList(req_hdr, HDR_PRAGMA); if (strListIsMember(&s, "no-cache", ',')) { if (Config.onoff.reload_into_ims) - EBIT_SET(request->flags, REQ_NOCACHE_HACK); + request->flags.nocache_hack = 1; else if (refresh_nocache_hack) - EBIT_SET(request->flags, REQ_NOCACHE_HACK); + request->flags.nocache_hack = 1; else - EBIT_SET(request->flags, REQ_NOCACHE); + request->flags.nocache = 1; } stringClean(&s); } @@ -693,14 +693,14 @@ clientInterpretRequestHeaders(clientHttpRequest * http) if (request->method == METHOD_GET) { request->range = httpHeaderGetRange(req_hdr); if (request->range) - EBIT_SET(request->flags, REQ_RANGE); + request->flags.range = 1; } if (httpHeaderHas(req_hdr, HDR_AUTHORIZATION)) - EBIT_SET(request->flags, REQ_AUTH); + request->flags.auth = 1; if (request->login[0] != '\0') - EBIT_SET(request->flags, REQ_AUTH); + request->flags.auth = 1; if (httpMsgIsPersistent(request->http_ver, req_hdr)) - EBIT_SET(request->flags, REQ_PROXY_KEEPALIVE); + request->flags.proxy_keepalive = 1; if (httpHeaderHas(req_hdr, HDR_VIA)) { String s = httpHeaderGetList(req_hdr, HDR_VIA); /* ThisCache cannot be a member of Via header, "1.0 ThisCache" can */ @@ -708,7 +708,7 @@ clientInterpretRequestHeaders(clientHttpRequest * http) debug(33, 1) ("WARNING: Forwarding loop detected for '%s'\n", http->uri); debug(33, 1) ("--> %s\n", strBuf(s)); - EBIT_SET(request->flags, REQ_LOOPDETECT); + request->flags.loopdetect = 1; } #if FORW_VIA_DB fvdbCountVia(strBuf(s)); @@ -731,9 +731,9 @@ clientInterpretRequestHeaders(clientHttpRequest * http) request->max_forwards = httpHeaderGetInt(req_hdr, HDR_MAX_FORWARDS); } if (clientCachable(http)) - EBIT_SET(request->flags, REQ_CACHABLE); + request->flags.cachable = 1; if (clientHierarchical(http)) - EBIT_SET(request->flags, REQ_HIERARCHICAL); + request->flags.hierarchical = 1; #if DELAY_POOLS if (delayClient(http)) { debug(33, 5) ("clientInterpretRequestHeaders: delay request class %d position %d\n", @@ -742,11 +742,11 @@ clientInterpretRequestHeaders(clientHttpRequest * http) } #endif debug(33, 5) ("clientInterpretRequestHeaders: REQ_NOCACHE = %s\n", - EBIT_TEST(request->flags, REQ_NOCACHE) ? "SET" : "NOT SET"); + request->flags.nocache ? "SET" : "NOT SET"); debug(33, 5) ("clientInterpretRequestHeaders: REQ_CACHABLE = %s\n", - EBIT_TEST(request->flags, REQ_CACHABLE) ? "SET" : "NOT SET"); + request->flags.cachable ? "SET" : "NOT SET"); debug(33, 5) ("clientInterpretRequestHeaders: REQ_HIERARCHICAL = %s\n", - EBIT_TEST(request->flags, REQ_HIERARCHICAL) ? "SET" : "NOT SET"); + request->flags.hierarchical ? "SET" : "NOT SET"); } static int @@ -812,9 +812,9 @@ clientHierarchical(clientHttpRequest * http) /* IMS needs a private key, so we can use the hierarchy for IMS only * if our neighbors support private keys */ - if (EBIT_TEST(request->flags, REQ_IMS) && !neighbors_do_private_keys) + if (request->flags.ims && !neighbors_do_private_keys) return 0; - if (EBIT_TEST(request->flags, REQ_AUTH)) + if (request->flags.auth) return 0; if (method == METHOD_TRACE) return 1; @@ -824,7 +824,7 @@ clientHierarchical(clientHttpRequest * http) for (p = Config.hierarchy_stoplist; p; p = p->next) if (strstr(url, p->key)) return 0; - if (EBIT_TEST(request->flags, REQ_LOOPDETECT)) + if (request->flags.loopdetect) return 0; if (request->protocol == PROTO_HTTP) return httpCachable(method); @@ -1025,11 +1025,11 @@ clientBuildReplyHeader(clientHttpRequest * http, HttpReply * rep) /* Only replies with valid Content-Length can be sent with keep-alive */ if (request->method != METHOD_HEAD && http->entry->mem_obj->reply->content_length < 0) - EBIT_CLR(request->flags, REQ_PROXY_KEEPALIVE); + request->flags.proxy_keepalive = 0; /* Signal keep-alive if needed */ httpHeaderPutStr(hdr, http->flags.accel ? HDR_CONNECTION : HDR_PROXY_CONNECTION, - EBIT_TEST(request->flags, REQ_PROXY_KEEPALIVE) ? "keep-alive" : "close"); + request->flags.proxy_keepalive ? "keep-alive" : "close"); /* Accept-Range header for cached objects if not there already */ if (is_hit && !httpHeaderHas(hdr, HDR_ACCEPT_RANGES)) httpHeaderPutStr(hdr, HDR_ACCEPT_RANGES, "bytes"); @@ -1145,7 +1145,7 @@ clientCacheHit(void *data, char *buf, ssize_t size) */ http->log_type = LOG_TCP_MISS; clientProcessMiss(http); - } else if (EBIT_TEST(r->flags, REQ_NOCACHE)) { + } else if (r->flags.nocache) { /* * This did not match a refresh pattern that overrides no-cache * we should honour the client no-cache header. @@ -1168,7 +1168,7 @@ clientCacheHit(void *data, char *buf, ssize_t size) clientProcessMiss(http); } memFree(MEM_4K_BUF, buf); - } else if (EBIT_TEST(r->flags, REQ_IMS)) { + } else if (r->flags.ims) { /* * Handle If-Modified-Since requests from the client */ @@ -1186,7 +1186,7 @@ clientCacheHit(void *data, char *buf, ssize_t size) memFree(MEM_4K_BUF, buf); storeUnregister(e, http); storeUnlockObject(e); - e = clientCreateStoreEntry(http, http->request->method, 0); + e = clientCreateStoreEntry(http, http->request->method, null_request_flags); http->entry = e; httpReplyParse(e->mem_obj->reply, mb.buf); storeAppend(e, mb.buf, mb.size); @@ -1533,7 +1533,7 @@ clientWriteComplete(int fd, char *bufnotused, size_t size, int errflag, void *da } else if (EBIT_TEST(entry->flag, ENTRY_BAD_LENGTH)) { debug(33, 5) ("clientWriteComplete: closing, ENTRY_BAD_LENGTH\n"); comm_close(fd); - } else if (EBIT_TEST(http->request->flags, REQ_PROXY_KEEPALIVE)) { + } else if (http->request->flags.proxy_keepalive) { debug(33, 5) ("clientWriteComplete: FD %d Keeping Alive\n", fd); clientKeepaliveNextRequest(http); } else { @@ -1572,7 +1572,7 @@ clientProcessOnlyIfCachedMiss(clientHttpRequest * http) err = errorCon(ERR_ONLY_IF_CACHED_MISS, HTTP_GATEWAY_TIMEOUT); err->request = requestLink(r); err->src_addr = http->conn->peer.sin_addr; - http->entry = clientCreateStoreEntry(http, r->method, 0); + http->entry = clientCreateStoreEntry(http, r->method, null_request_flags); errorAppendEntry(http->entry, err); } @@ -1600,11 +1600,11 @@ clientProcessRequest2(clientHttpRequest * http) /* Special entries are always hits, no matter what the client says */ http->entry = e; return LOG_TCP_HIT; - } else if (EBIT_TEST(r->flags, REQ_NOCACHE_HACK)) { + } else if (r->flags.nocache_hack) { http->entry = NULL; ipcacheReleaseInvalid(r->host); return LOG_TCP_CLIENT_REFRESH_MISS; - } else if (EBIT_TEST(r->flags, REQ_NOCACHE)) { + } else if (r->flags.nocache) { http->entry = NULL; ipcacheReleaseInvalid(r->host); return LOG_TCP_CLIENT_REFRESH_MISS; @@ -1633,7 +1633,7 @@ clientProcessRequest(clientHttpRequest * http) return; } else if (r->method == METHOD_TRACE) { if (r->max_forwards == 0) { - http->entry = clientCreateStoreEntry(http, r->method, 0); + http->entry = clientCreateStoreEntry(http, r->method, null_request_flags); storeReleaseRequest(http->entry); storeBuffer(http->entry); rep = httpReplyCreate(); @@ -1709,12 +1709,12 @@ clientProcessMiss(clientHttpRequest * http) /* * Deny loops when running in accelerator/transproxy mode. */ - if (http->flags.accel && EBIT_TEST(r->flags, REQ_LOOPDETECT)) { + if (http->flags.accel && r->flags.loopdetect) { http->al.http.code = HTTP_FORBIDDEN; err = errorCon(ERR_ACCESS_DENIED, HTTP_FORBIDDEN); err->request = requestLink(r); err->src_addr = http->conn->peer.sin_addr; - http->entry = clientCreateStoreEntry(http, r->method, 0); + http->entry = clientCreateStoreEntry(http, r->method, null_request_flags); errorAppendEntry(http->entry, err); return; } @@ -2038,7 +2038,7 @@ clientReadRequest(int fd, void *data) debug(33, 1) ("clientReadRequest: FD %d Invalid Request\n", fd); err = errorCon(ERR_INVALID_REQ, HTTP_BAD_REQUEST); err->request_hdrs = xstrdup(conn->in.buf); - http->entry = clientCreateStoreEntry(http, method, 0); + http->entry = clientCreateStoreEntry(http, method, null_request_flags); errorAppendEntry(http->entry, err); safe_free(prefix); break; @@ -2049,7 +2049,7 @@ clientReadRequest(int fd, void *data) err->src_addr = conn->peer.sin_addr; err->url = xstrdup(http->uri); http->al.http.code = err->http_status; - http->entry = clientCreateStoreEntry(http, method, 0); + http->entry = clientCreateStoreEntry(http, method, null_request_flags); errorAppendEntry(http->entry, err); safe_free(prefix); break; @@ -2083,7 +2083,7 @@ clientReadRequest(int fd, void *data) err->src_addr = conn->peer.sin_addr; err->request = requestLink(request); http->al.http.code = err->http_status; - http->entry = clientCreateStoreEntry(http, request->method, 0); + http->entry = clientCreateStoreEntry(http, request->method, null_request_flags); errorAppendEntry(http->entry, err); break; } @@ -2092,7 +2092,7 @@ clientReadRequest(int fd, void *data) err->src_addr = conn->peer.sin_addr; err->request = requestLink(request); http->al.http.code = err->http_status; - http->entry = clientCreateStoreEntry(http, request->method, 0); + http->entry = clientCreateStoreEntry(http, request->method, null_request_flags); errorAppendEntry(http->entry, err); break; } @@ -2139,7 +2139,7 @@ clientReadRequest(int fd, void *data) debug(33, 0) ("This request = %d bytes.\n", (int) conn->in.offset); err = errorCon(ERR_INVALID_REQ, HTTP_REQUEST_ENTITY_TOO_LARGE); - http->entry = clientCreateStoreEntry(http, request->method, 0); + http->entry = clientCreateStoreEntry(http, request->method, null_request_flags); errorAppendEntry(http->entry, err); return; } @@ -2257,7 +2257,7 @@ CheckQuickAbort2(const clientHttpRequest * http) int minlen; int expectlen; - if (!EBIT_TEST(http->request->flags, REQ_CACHABLE)) + if (!http->request->flags.cachable) return 1; if (EBIT_TEST(http->entry->flag, KEY_PRIVATE)) return 1; diff --git a/src/enums.h b/src/enums.h index 32b8329976..bcd5d4662a 100644 --- a/src/enums.h +++ b/src/enums.h @@ -1,6 +1,6 @@ /* - * $Id: enums.h,v 1.121 1998/08/20 22:45:47 wessels Exp $ + * $Id: enums.h,v 1.122 1998/08/21 03:15:16 wessels Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -464,25 +464,6 @@ enum { ERR_FLAG_CBDATA }; -/* - * These are request_t->flags - */ -enum { - REQ_RANGE, - REQ_NOCACHE, - REQ_IMS, - REQ_AUTH, - REQ_CACHABLE, - REQ_HIERARCHICAL, - REQ_LOOPDETECT, - REQ_PROXY_KEEPALIVE, - REQ_PROXYING, - REQ_REFRESH, - REQ_USED_PROXY_AUTH, - REQ_REDIRECTED, - REQ_NOCACHE_HACK /* for changing/ignoring no-cache requests */ -}; - enum { HELPER_ALIVE, HELPER_BUSY, diff --git a/src/globals.h b/src/globals.h index 317c8e73fb..f2d62ad96e 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1,6 +1,6 @@ /* - * $Id: globals.h,v 1.64 1998/08/20 22:45:48 wessels Exp $ + * $Id: globals.h,v 1.65 1998/08/21 03:15:17 wessels Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -139,3 +139,4 @@ extern icpUdpData *IcpQueueHead; /* NULL */ extern time_t delay_pools_last_update; /* 0 */ #endif extern int refresh_nocache_hack; /* 0 */ +extern request_flags null_request_flags; diff --git a/src/http.cc b/src/http.cc index dc06e5b5eb..7ff0e2ac5f 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.311 1998/08/20 22:29:59 wessels Exp $ + * $Id: http.cc,v 1.312 1998/08/21 03:15:17 wessels Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -176,7 +176,7 @@ httpCachableReply(HttpStateData * httpState) return 0; if (EBIT_TEST(cc_mask, CC_NO_STORE)) return 0; - if (EBIT_TEST(httpState->request->flags, REQ_AUTH)) { + if (httpState->request->flags.auth) { /* * Responses to requests with authorization may be cached * only if a Cache-Control: public reply header is present. @@ -577,7 +577,7 @@ httpBuildRequestHeader(request_t * request, * no reason to filter out if the reply will not be cachable * or if we cannot parse the specs */ filter_range = - orig_request->range && EBIT_TEST(orig_request->flags, REQ_CACHABLE); + orig_request->range && orig_request->flags.cachable; strConnection = httpHeaderGetList(hdr_in, HDR_CONNECTION); while ((e = httpHeaderGetEntry(hdr_in, &pos))) { @@ -588,12 +588,12 @@ httpBuildRequestHeader(request_t * request, switch (e->id) { case HDR_PROXY_AUTHORIZATION: /* If we're not going to do proxy auth, then it must be passed on */ - if (!EBIT_TEST(request->flags, REQ_USED_PROXY_AUTH)) + if (!request->flags.used_proxy_auth) httpHeaderAddEntry(hdr_out, httpHeaderEntryClone(e)); break; case HDR_HOST: /* Don't use client's Host: header for redirected requests */ - if (!EBIT_TEST(request->flags, REQ_REDIRECTED)) + if (!request->flags.redirected) httpHeaderAddEntry(hdr_out, httpHeaderEntryClone(e)); break; case HDR_IF_MODIFIED_SINCE: @@ -784,7 +784,7 @@ httpStart(FwdState * fwdState, int fd) proxy_req->flags = orig_req->flags; httpState->request = requestLink(proxy_req); httpState->orig_request = requestLink(orig_req); - EBIT_SET(proxy_req->flags, REQ_PROXYING); + proxy_req->flags.proxying = 1; /* * This NEIGHBOR_PROXY_ONLY check probably shouldn't be here. * We might end up getting the object from somewhere else if, diff --git a/src/mime.cc b/src/mime.cc index 68d19d949d..29935fe258 100644 --- a/src/mime.cc +++ b/src/mime.cc @@ -1,6 +1,6 @@ /* - * $Id: mime.cc,v 1.77 1998/08/17 21:51:18 wessels Exp $ + * $Id: mime.cc,v 1.78 1998/08/21 03:15:18 wessels Exp $ * * DEBUG: section 25 MIME Parsing * AUTHOR: Harvest Derived @@ -370,7 +370,7 @@ mimeLoadIconFile(const char *icon) { int fd; int n; - int flags; + request_flags flags; struct stat sb; StoreEntry *e; LOCAL_ARRAY(char, path, MAXPATHLEN); @@ -395,8 +395,8 @@ mimeLoadIconFile(const char *icon) debug(50, 0) ("mimeLoadIconFile: FD %d: fstat: %s\n", fd, xstrerror()); return; } - flags = 0; - EBIT_SET(flags, REQ_CACHABLE); + flags = null_request_flags; + flags.cachable = 1; e = storeCreateEntry(url, url, flags, diff --git a/src/neighbors.cc b/src/neighbors.cc index b0df3b2ca3..43d91a9fd7 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -1,6 +1,6 @@ /* - * $Id: neighbors.cc,v 1.233 1998/08/18 19:14:05 wessels Exp $ + * $Id: neighbors.cc,v 1.234 1998/08/21 03:15:19 wessels Exp $ * * DEBUG: section 15 Neighbor Routines * AUTHOR: Harvest Derived @@ -119,10 +119,10 @@ peerAllowedToUse(const peer * p, request_t * request) int do_ping = 1; aclCheck_t checklist; assert(request != NULL); - if (EBIT_TEST(request->flags, REQ_NOCACHE)) + if (request->flags.nocache) if (neighborType(p, request) == PEER_SIBLING) return 0; - if (EBIT_TEST(request->flags, REQ_REFRESH)) + if (request->flags.refresh) if (neighborType(p, request) == PEER_SIBLING) return 0; if (p->pinglist == NULL && p->access == NULL) @@ -157,7 +157,7 @@ peerWouldBePinged(const peer * p, request_t * request) /* the case below seems strange, but can happen if the * URL host is on the other side of a firewall */ if (p->type == PEER_SIBLING) - if (!EBIT_TEST(request->flags, REQ_HIERARCHICAL)) + if (!request->flags.hierarchical) return 0; if (p->icp_port == echo_port) if (!neighborUp(p)) @@ -964,7 +964,7 @@ peerCountMcastPeersStart(void *data) assert(p->type == PEER_MULTICAST); p->mcast.flags &= ~PEER_COUNT_EVENT_PENDING; snprintf(url, MAX_URL, "http://%s/", inet_ntoa(p->in_addr.sin_addr)); - fake = storeCreateEntry(url, url, 0, METHOD_GET); + fake = storeCreateEntry(url, url, null_request_flags, METHOD_GET); psstate->request = requestLink(urlParse(METHOD_GET, url)); psstate->entry = fake; psstate->callback = NULL; diff --git a/src/net_db.cc b/src/net_db.cc index 3fa9c4e06a..5e2eeb645f 100644 --- a/src/net_db.cc +++ b/src/net_db.cc @@ -1,6 +1,6 @@ /* - * $Id: net_db.cc,v 1.123 1998/08/20 15:30:23 wessels Exp $ + * $Id: net_db.cc,v 1.124 1998/08/21 03:15:20 wessels Exp $ * * DEBUG: section 38 Network Measurement Database * AUTHOR: Duane Wessels @@ -1057,14 +1057,14 @@ netdbExchangeStart(void *data) requestLink(ex->r); assert(NULL != ex->r); ex->r->http_ver = 1.0; - ex->e = storeCreateEntry(uri, uri, 0, METHOD_GET); + ex->e = storeCreateEntry(uri, uri, null_request_flags, METHOD_GET); ex->buf_sz = 4096;; ex->buf = memAllocate(MEM_4K_BUF); assert(NULL != ex->e); storeClientListAdd(ex->e, ex); storeClientCopy(ex->e, ex->seen, ex->used, ex->buf_sz, ex->buf, netdbExchangeHandleReply, ex); - EBIT_SET(ex->r->flags, REQ_LOOPDETECT); /* cheat! -- force direct */ + ex->r->flags.loopdetect = 1; /* cheat! -- force direct */ fwdStart(-1, ex->e, ex->r, any_addr); #endif } diff --git a/src/peer_digest.cc b/src/peer_digest.cc index 187cbd0111..2656f98994 100644 --- a/src/peer_digest.cc +++ b/src/peer_digest.cc @@ -1,6 +1,6 @@ /* - * $Id: peer_digest.cc,v 1.44 1998/07/24 00:55:03 wessels Exp $ + * $Id: peer_digest.cc,v 1.45 1998/08/21 03:15:20 wessels Exp $ * * DEBUG: section 72 Peer Digest Routines * AUTHOR: Alex Rousskov @@ -262,9 +262,9 @@ peerDigestRequest(peer * p) fetch->start_time = squid_curtime; p->digest.last_req_timestamp = squid_curtime; global_last_req_timestamp = squid_curtime; - EBIT_SET(req->flags, REQ_CACHABLE); + req->flags.cachable = 1; /* the rest is based on clientProcessExpired() */ - EBIT_SET(req->flags, REQ_REFRESH); + req->flags.refresh = 1; old_e = fetch->old_entry = storeGet(key); if (old_e) { debug(72, 5) ("peerDigestRequest: found old entry\n"); diff --git a/src/peer_select.cc b/src/peer_select.cc index 7bf1e91d45..3c4ff53838 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -1,6 +1,6 @@ /* - * $Id: peer_select.cc,v 1.75 1998/08/20 22:30:00 wessels Exp $ + * $Id: peer_select.cc,v 1.76 1998/08/21 03:15:21 wessels Exp $ * * DEBUG: section 44 Peer Selection Algorithm * AUTHOR: Duane Wessels @@ -107,7 +107,7 @@ peerSelectIcpPing(request_t * request, int direct, StoreEntry * entry) if (entry->ping_status != PING_NONE) return 0; assert(direct != DIRECT_YES); - if (!EBIT_TEST(request->flags, REQ_HIERARCHICAL) && direct != DIRECT_NO) + if (!request->flags.hierarchical && direct != DIRECT_NO) return 0; if (EBIT_TEST(entry->flag, KEY_PRIVATE) && !neighbors_do_private_keys) if (direct != DIRECT_NO) @@ -282,7 +282,7 @@ peerSelectFoo(ps_state * psstate) return; } else if (psstate->always_direct > 0) { direct = DIRECT_YES; - } else if (EBIT_TEST(request->flags, REQ_LOOPDETECT)) { + } else if (request->flags.loopdetect) { direct = DIRECT_YES; } else { direct = DIRECT_MAYBE; diff --git a/src/protos.h b/src/protos.h index 11001d85ae..6714efde85 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.252 1998/08/20 02:49:11 wessels Exp $ + * $Id: protos.h,v 1.253 1998/08/21 03:15:22 wessels Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -119,7 +119,7 @@ extern void clientPurgeRequest(clientHttpRequest *); extern int checkNegativeHit(StoreEntry *); extern void clientHttpConnectionsOpen(void); extern void clientHttpConnectionsClose(void); -extern StoreEntry *clientCreateStoreEntry(clientHttpRequest *, method_t, int); +extern StoreEntry *clientCreateStoreEntry(clientHttpRequest *, method_t, request_flags); extern int isTcpHit(log_type); extern int commSetNonBlocking(int fd); @@ -728,7 +728,7 @@ extern void stmemFreeData(mem_hdr *); */ extern StoreEntry *new_StoreEntry(int, const char *, const char *); extern StoreEntry *storeGet(const cache_key *); -extern StoreEntry *storeCreateEntry(const char *, const char *, int, method_t); +extern StoreEntry *storeCreateEntry(const char *, const char *, request_flags, method_t); extern void storeSetPublicKey(StoreEntry *); extern void storeComplete(StoreEntry *); #ifdef PPNR_WIP diff --git a/src/refresh.cc b/src/refresh.cc index addda2729c..dc1d1eeb80 100644 --- a/src/refresh.cc +++ b/src/refresh.cc @@ -1,7 +1,7 @@ /* - * $Id: refresh.cc,v 1.32 1998/08/20 22:45:49 wessels Exp $ + * $Id: refresh.cc,v 1.33 1998/08/21 03:15:23 wessels Exp $ * * DEBUG: section 22 Refresh Calculation * AUTHOR: Harvest Derived @@ -138,7 +138,7 @@ refreshCheck(const StoreEntry * entry, request_t * request, time_t delta) debug(22, 3) ("refreshCheck: age = %d\n", (int) age); debug(22, 3) ("\tcheck_time:\t%s\n", mkrfc1123(check_time)); debug(22, 3) ("\tentry->timestamp:\t%s\n", mkrfc1123(entry->timestamp)); - if (EBIT_TEST(request->flags, REQ_NOCACHE_HACK)) { + if (request->flags.nocache_hack) { if (ignore_reload) { /* The clients no-cache header is ignored */ debug(22, 3) ("refreshCheck: MAYBE: ignore-reload\n"); @@ -149,7 +149,7 @@ refreshCheck(const StoreEntry * entry, request_t * request, time_t delta) } else { /* The clients no-cache header is not overridden on this request */ debug(22, 3) ("refreshCheck: YES: client reload\n"); - EBIT_SET(request->flags, REQ_NOCACHE); + request->flags.nocache = 1; return 1; } } diff --git a/src/store.cc b/src/store.cc index 1ba6fdc60e..f16e4d0c89 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.447 1998/08/20 22:30:04 wessels Exp $ + * $Id: store.cc,v 1.448 1998/08/21 03:15:24 wessels Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -327,21 +327,21 @@ storeSetPublicKey(StoreEntry * e) } StoreEntry * -storeCreateEntry(const char *url, const char *log_url, int flags, method_t method) +storeCreateEntry(const char *url, const char *log_url, request_flags flags, method_t method) { StoreEntry *e = NULL; MemObject *mem = NULL; - debug(20, 3) ("storeCreateEntry: '%s' icp flags=%x\n", url, flags); + debug(20, 3) ("storeCreateEntry: '%s'\n", url); e = new_StoreEntry(STORE_ENTRY_WITH_MEMOBJ, url, log_url); e->lock_count = 1; /* Note lock here w/o calling storeLock() */ mem = e->mem_obj; mem->method = method; - if (neighbors_do_private_keys || !EBIT_TEST(flags, REQ_HIERARCHICAL)) + if (neighbors_do_private_keys || !flags.hierarchical) storeSetPrivateKey(e); else storeSetPublicKey(e); - if (EBIT_TEST(flags, REQ_CACHABLE)) { + if (flags.cachable) { EBIT_SET(e->flag, ENTRY_CACHABLE); EBIT_CLR(e->flag, RELEASE_REQUEST); } else { diff --git a/src/store_digest.cc b/src/store_digest.cc index 46c8d18aec..864f6fbfc4 100644 --- a/src/store_digest.cc +++ b/src/store_digest.cc @@ -1,5 +1,5 @@ /* - * $Id: store_digest.cc,v 1.25 1998/07/22 20:37:58 wessels Exp $ + * $Id: store_digest.cc,v 1.26 1998/08/21 03:15:25 wessels Exp $ * * DEBUG: section 71 Store Digest Manager * AUTHOR: Alex Rousskov @@ -290,7 +290,7 @@ storeDigestRebuildStep(void *datanotused) static void storeDigestRewriteStart(void *datanotused) { - int flags; + request_flags flags; char *url; StoreEntry *e; @@ -303,8 +303,8 @@ storeDigestRewriteStart(void *datanotused) debug(71, 2) ("storeDigestRewrite: start rewrite #%d\n", sd_state.rewrite_count + 1); /* make new store entry */ url = internalLocalUri("/squid-internal-periodic/", StoreDigestUrlPath); - flags = 0; - EBIT_SET(flags, REQ_CACHABLE); + flags = null_request_flags; + flags.cachable = 1; sd_state.rewrite_lock = e = storeCreateEntry(url, url, flags, METHOD_GET); assert(sd_state.rewrite_lock); cbdataAdd(sd_state.rewrite_lock, MEM_DONTFREE); diff --git a/src/structs.h b/src/structs.h index 41eae7fc48..fa3641fe95 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.207 1998/08/20 22:45:50 wessels Exp $ + * $Id: structs.h,v 1.208 1998/08/21 03:15:26 wessels Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -1184,6 +1184,22 @@ struct _SwapDir { int swaplog_fd; }; +struct _request_flags { + int range:1; + int nocache:1; + int ims:1; + int auth:1; + int cachable:1; + int hierarchical:1; + int loopdetect:1; + int proxy_keepalive:1; + int proxying:1; + int refresh:1; + int used_proxy_auth:1; + int redirected:1; + int nocache_hack:1; /* for changing/ignoring no-cache requests */ +}; + struct _request_t { method_t method; protocol_t protocol; @@ -1194,7 +1210,7 @@ struct _request_t { String urlpath; char *canonical; int link_count; /* free when zero */ - int flags; + request_flags flags; HttpHdrCc *cache_control; HttpHdrRange *range; time_t max_age; diff --git a/src/typedefs.h b/src/typedefs.h index dc15549c54..8f98d107cd 100644 --- a/src/typedefs.h +++ b/src/typedefs.h @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.70 1998/08/18 21:15:44 wessels Exp $ + * $Id: typedefs.h,v 1.71 1998/08/21 03:15:27 wessels Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -130,6 +130,7 @@ typedef struct _store_client store_client; typedef struct _MemObject MemObject; typedef struct _StoreEntry StoreEntry; typedef struct _SwapDir SwapDir; +typedef struct _request_flags request_flags; typedef struct _request_t request_t; typedef struct _AccessLogEntry AccessLogEntry; typedef struct _cachemgr_passwd cachemgr_passwd; diff --git a/src/url.cc b/src/url.cc index 34dceb0fb7..8248cc023f 100644 --- a/src/url.cc +++ b/src/url.cc @@ -1,6 +1,6 @@ /* - * $Id: url.cc,v 1.106 1998/08/19 04:32:15 wessels Exp $ + * $Id: url.cc,v 1.107 1998/08/21 03:15:29 wessels Exp $ * * DEBUG: section 23 URL Parsing * AUTHOR: Duane Wessels @@ -109,6 +109,7 @@ urlInitialize(void) { debug(23, 5) ("urlInitialize: Initializing...\n"); assert(sizeof(ProtocolStr) == (PROTO_MAX + 1) * sizeof(char *)); + memset(&null_request_flags, '\0', sizeof(null_request_flags)); } method_t diff --git a/src/urn.cc b/src/urn.cc index 14e2fe7cbc..597f88abe0 100644 --- a/src/urn.cc +++ b/src/urn.cc @@ -1,7 +1,7 @@ /* * - * $Id: urn.cc,v 1.42 1998/08/14 09:22:42 wessels Exp $ + * $Id: urn.cc,v 1.43 1998/08/21 03:15:29 wessels Exp $ * * DEBUG: section 52 URN Parsing * AUTHOR: Kostas Anagnostakis @@ -140,7 +140,7 @@ urnStart(request_t * r, StoreEntry * e) } httpHeaderPutStr(&urlres_r->header, HDR_ACCEPT, "text/plain"); if ((urlres_e = storeGet(k)) == NULL) { - urlres_e = storeCreateEntry(urlres, urlres, 0, METHOD_GET); + urlres_e = storeCreateEntry(urlres, urlres, null_request_flags, METHOD_GET); storeClientListAdd(urlres_e, urnState); fwdStart(-1, urlres_e, urlres_r, any_addr); } else {