/*
- * $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
/*
- * $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/
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
};
/*
- * $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
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);
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);
/*
- * $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
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)
* 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?
StoreEntry * entry,
HttpHeader * hdr_out,
int cfd,
- int flags)
+ http_state_flags flags)
{
/* building buffer for complex strings */
#define BBUF_SZ (MAX_URL+32)
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");
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",
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,
/*
- * $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
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;
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
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));
peerCountMcastPeersDone,
psstate,
(double) Config.Timeout.mcast_icp_query, 1);
- p->mcast.flags |= PEER_COUNTING;
+ p->mcast.flags.counting = 1;
peerCountMcastPeersSchedule(p, MCAST_COUNT_RATE);
}
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,
/*
- * $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
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 */
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);
}
{
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) {
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;
}
}
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 */ ) {
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",
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);
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),
} 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));
/* 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));
}
/*
- * $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/
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);
/*
- * $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
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);
/*
- * $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/
HttpBody body; /* for small constant memory-resident text bodies only */
};
+struct _http_state_flags {
+ int proxying:1;
+ int keepalive:1;
+};
struct _HttpStateData {
StoreEntry *entry;
int eof; /* reached end-of-object? */
request_t *orig_request;
int fd;
- int flags;
+ http_state_flags flags;
FwdState *fwdState;
};
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 */
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 */
char *redirect_url;
ERCB *callback;
void *callback_data;
- int flags;
+ struct {
+ int flag_cbdata:1;
+ } flags;
struct {
char *request;
char *reply;
/*
- * $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/
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;
/*
*
- * $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 {
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);
}
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);