--------------------- PatchSet 6178 Date: 2004/03/11 06:02:57 Author: ymc Branch: dtd Tag: (none) Log: dtd010104 changes Members: src/HttpReply.c:1.3.4.3.10.1->1.3.4.3.10.2 src/client_side.c:1.5.2.9.2.11.2.9->1.5.2.9.2.11.2.10 src/forward.c:1.4.4.1.10.5.2.4->1.4.4.1.10.5.2.5 src/http.c:1.4.4.4.2.8.2.3->1.4.4.4.2.8.2.4 src/protos.h:1.4.4.9.2.4->1.4.4.9.2.4.2.1 src/store.c:1.4.4.5.6.16.2.2->1.4.4.5.6.16.2.3 src/structs.h:1.6.2.11.2.5.2.1->1.6.2.11.2.5.2.2 Index: squid/src/HttpReply.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/HttpReply.c,v retrieving revision 1.3.4.3.10.1 retrieving revision 1.3.4.3.10.2 diff -u -r1.3.4.3.10.1 -r1.3.4.3.10.2 --- squid/src/HttpReply.c 24 Dec 2002 04:58:04 -0000 1.3.4.3.10.1 +++ squid/src/HttpReply.c 11 Mar 2004 06:02:57 -0000 1.3.4.3.10.2 @@ -1,6 +1,6 @@ /* - * $Id: HttpReply.c,v 1.3.4.3.10.1 2002/12/24 04:58:04 ymc Exp $ + * $Id: HttpReply.c,v 1.3.4.3.10.2 2004/03/11 06:02:57 ymc Exp $ * * DEBUG: section 58 HTTP Reply (Response) * AUTHOR: Alex Rousskov @@ -241,18 +241,8 @@ if (ctype) { httpHeaderPutStr(hdr, HDR_CONTENT_TYPE, ctype); stringInit(&reply->content_type, ctype); -#ifdef DTD - stringInit(&reply->content_type, ctype); - } - else { -#else } else -#endif reply->content_type = StringNull; -#ifdef DTD - reply->content_md5 = StringNull; - } -#endif if (clen >= 0) httpHeaderPutInt(hdr, HDR_CONTENT_LENGTH, clen); if (expires >= 0) @@ -357,8 +347,8 @@ #ifdef DTD str = base64_decode(httpHeaderGetStr(hdr, HDR_CONTENT_MD5)); if (str) - stringLimitInit(&rep->content_md5, str, strlen(str)); - else + stringLimitInit(&rep->content_md5, str, MD5_DIGEST_CHARS); + else rep->content_md5 = StringNull; #endif rep->keep_alive = httpMsgIsPersistent(rep->sline.version, &rep->header); Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.5.2.9.2.11.2.9 retrieving revision 1.5.2.9.2.11.2.10 diff -u -r1.5.2.9.2.11.2.9 -r1.5.2.9.2.11.2.10 --- squid/src/client_side.c 3 Jan 2003 06:33:33 -0000 1.5.2.9.2.11.2.9 +++ squid/src/client_side.c 11 Mar 2004 06:02:57 -0000 1.5.2.9.2.11.2.10 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.5.2.9.2.11.2.9 2003/01/03 06:33:33 ymc Exp $ + * $Id: client_side.c,v 1.5.2.9.2.11.2.10 2004/03/11 06:02:57 ymc Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -95,11 +95,7 @@ static void clientCheckNoCacheDone(int answer, void *data); static STCB clientHandleIMSReply; #ifdef DTD -static void clientProcessDTD(clientHttpRequest * http); -static int clientDTDCachableReply(clientHttpRequest * httpState); static STCB clientHandleHEADReply; -static void clientCacheDTDHit(void *data, char *buf, ssize_t size); -static InstanceEntry * clientDTDCreateStoreEntry(clientHttpRequest * h, method_t m, request_flags flags); #endif #ifdef DSA static int clientGetsOldEntry(InstanceEntry * new, InstanceEntry * old, request_t * request); @@ -128,67 +124,6 @@ static int clientReplyBodyTooLarge(int clen); static int clientRequestBodyTooLarge(int clen); -static int -checkAccelOnly(clientHttpRequest * http) -{ - /* return TRUE if someone makes a proxy request to us and - * we are in httpd-accel only mode */ - if (!Config2.Accel.on) - return 0; - if (Config.onoff.accel_with_proxy) - return 0; - if (http->request->protocol == PROTO_CACHEOBJ) - return 0; - if (http->flags.accel) - return 0; - return 1; -} - -#if USE_IDENT -static void -clientIdentDone(const char *ident, void *data) -{ - ConnStateData *conn = data; - if (ident) - xstrncpy(conn->ident, ident, sizeof(conn->ident)); - else - xstrncpy(conn->ident, "-", sizeof(conn->ident)); -} -#endif - -static aclCheck_t * -clientAclChecklistCreate(const acl_access * acl, const clientHttpRequest * http) -{ - aclCheck_t *ch; - ConnStateData *conn = http->conn; - ch = aclChecklistCreate(acl, - http->request, - conn->ident); -#if USE_IDENT - /* - * hack for ident ACL. It needs to get full addresses, and a - * place to store the ident result on persistent connections... - */ - ch->conn = conn; - cbdataLock(ch->conn); -#endif - return ch; -} - -void -clientAccessCheck(void *data) -{ - clientHttpRequest *http = data; - if (checkAccelOnly(http)) { - /* deny proxy requests in accel_only mode */ - debug(33, 1) ("clientAccessCheck: proxy request denied in accel_only mode\n"); - clientAccessCheckDone(ACCESS_DENIED, http); - return; - } - http->acl_checklist = clientAclChecklistCreate(Config.accessList.http, http); - aclNBCheck(http->acl_checklist, clientAccessCheckDone, http); -} - #ifdef DTD static void clientHandleHEADReply(void *data, char *buf, ssize_t size) @@ -243,65 +178,73 @@ return; } } else { - request_t * r = http->request; MemObject * mem = entry->mem_obj; - mem->method = METHOD_GET; - r->method = METHOD_GET; /* now we got the HEAD reply, see what we get in Content-MD5 */ - if (clientDTDCachableReply(http) && strLen(mem->reply->content_md5) == MD5_DIGEST_CHARS) { + if (strLen(mem->reply->content_md5) == MD5_DIGEST_CHARS) { StoreEntry * p = storeGet(strBuf(mem->reply->content_md5)); - - if (p) { /* DTD hit */ - /* need to clear the memory copy such that it can load from disk */ -// http->entry->p->lock_count = 1; /* force releasse in unlock */ - if (entry->hash.key) { - storeKeyFree(entry->hash.key); - entry->hash.key = NULL; - } - entry->hash.key = storeKeyDup(strBuf(mem->reply->content_md5)); - EBIT_CLR(entry->flags, KEY_PRIVATE); + if (p && storeValidToSend(p)) { /* DTD hit */ +#if 0 + int unlink_request = 0; + + if (http->old_entry->p->mem_obj->request == NULL) { + http->old_entry->p->mem_obj->request = requestLink(mem->request); + unlink_request = 1; + } +#endif + EBIT_SET(http->entry->p->flags, ENTRY_FWD_HDR_WAIT); + storeTimestampsSet(http->old_entry); + http->old_entry->lastmod = http->entry->lastmod; +// arrayDelete(http->entry->p->instances, http->entry); + storeUnregister(http->sc, http->entry->p, http); + http->sc = http->old_sc; + storeUnlockObject(http->entry->p); + http->entry = http->old_entry; + http->entry->timestamp = squid_curtime; +#if 0 + if (unlink_request) { + requestUnlink(http->entry->p->mem_obj->request); + http->entry->p->mem_obj->request = NULL; + } +#endif + http->old_entry = NULL; + http->old_sc = NULL; + /* set the StoreEntry for DTD to the parameters of the + * StoreEntry in cache */ +// storeUnregister(http->sc, http->entry->p, http); + EBIT_CLR(http->entry->flags, ENTRY_DISPATCHED); + if (http->entry->p->hash.key) { + storeKeyFree(http->entry->p->hash.key); + http->entry->p->hash.key = NULL; + } + http->entry->p->hash.key = storeKeyDup(strBuf(mem->reply->content_md5)); storeAddInstanceEntry(p, http->entry); -// http->entry->p = entry; // set it back to the original - if (http->entry->p->instances->count == 0) arrayAppend(http->entry->p->instances, http->entry); - http->old_entry = http->entry; - http->entry = new_InstanceEntry(STORE_ENTRY_WITHOUT_MEMOBJ, http->uri, http->log_uri); - http->entry->expires = http->old_entry->expires; - http->entry->lastmod = http->old_entry->lastmod; - http->entry->timestamp = http->old_entry->timestamp; - http->entry->flags = http->old_entry->flags; - http->entry->p = p; -// http->entry->hash.key = storeKeyDup(http->old_entry->hash.key); - storeSetPrivateKey(http->old_entry); - EBIT_CLR(http->old_entry->p->flags, ENTRY_CACHABLE); - EBIT_CLR(http->old_entry->flags, ENTRY_CACHABLE); -// storeUnregister(http->sc, http->old_entry->p, http); -// storeUnlockObject(http->old_entry->p); - http->old_sc = http->sc; - storeLockObject(p); - storeCreateMemObject(p, http->uri, http->log_uri); - p->mem_obj->method = METHOD_GET; - storeSetPublicKey(http->entry); - /* - p->mem_obj->fd = mem->fd; - mem->fd = -1; - dlinkDelete(&http->sc->node, &mem->clients); - mem->nclients--; - dlinkAdd(http->sc, &http->sc->node, &p->mem_obj->clients); - p->mem_obj->nclients++; - storeAbort(http->old_entry->p); -// http->entry->p = p; - http->sc->entry = p; + EBIT_CLR(http->entry->p->flags, KEY_PRIVATE); + EBIT_SET(http->entry->p->flags, ENTRY_FWD_HDR_WAIT); + http->entry->p->flags = p->flags; + http->entry->p->mem_obj->object_sz = -1; + http->entry->p->swap_file_sz = p->swap_file_sz; + http->entry->p->swap_filen = p->swap_filen; + http->entry->p->swap_dirn = p->swap_dirn; + http->entry->p->store_status = STORE_OK; + http->entry->p->swap_status = SWAPOUT_DONE; + http->request->method = METHOD_GET; http->sc->type = STORE_DISK_CLIENT; - */ - http->sc = storeClientListAdd(p, http); + http->out.offset = 0; + p->lastref = http->entry->p->lastref; + p->refcount += http->entry->p->refcount; + + /* this section copies from clientProcessRequest */ +// storeLockObject(http->entry->p); + storeCreateMemObject(http->entry->p, http->uri, http->log_uri); +// http->sc = storeClientListAdd(http->entry->p, http); http->log_type = LOG_TCP_HIT; -/* the old code to handle a HIT */ - storeClientCopy(http->sc, p, - http->out.offset + mem->inmem_hi, + + storeClientCopy(http->sc, http->entry->p, + http->out.offset, http->out.offset, CLIENT_SOCK_SZ, memAllocate(MEM_CLIENT_SOCK_BUF), - clientCacheDTDHit, + clientCacheHit, http); } else { /* DTD miss */ @@ -309,8 +252,9 @@ storeKeyFree(entry->hash.key); entry->hash.key = NULL; } - http->entry->p->hash.key = storeKeyDup(strBuf(mem->reply->content_md5)); - EBIT_CLR(http->entry->p->flags, KEY_PRIVATE); + entry->hash.key = storeKeyDup(strBuf(mem->reply->content_md5)); + EBIT_CLR(entry->flags, KEY_PRIVATE); +assert(entry->hash.key); storeClientCopy(http->sc, http->entry->p, mem->inmem_hi, 0, CLIENT_SOCK_SZ, memAllocate(MEM_CLIENT_SOCK_BUF), clientSendMoreData, http); } } @@ -319,301 +263,68 @@ } } } - -/* - * Prepare to fetch the object as it's a cache miss of some kind. - */ -static void -clientProcessDTD(clientHttpRequest * http) -{ - char *url = http->uri; - request_t *r = http->request; - ErrorState *err = NULL; - debug(33, 4) ("clientProcessMiss: '%s %s'\n", - RequestMethodStr[r->method], url); - /* - * We might have a left-over StoreEntry from a failed cache hit - * or IMS request. - */ - if (http->entry) { - if (EBIT_TEST(http->entry->flags, ENTRY_SPECIAL)) { - debug(33, 0) ("clientProcessMiss: miss on a special object (%s).\n", url); - debug(33, 0) ("\tlog_type = %s\n", log_tags[http->log_type]); - storeEntryDump(http->entry->p, 1); - } - storeUnregister(http->sc, http->entry->p, http); - http->sc = NULL; - storeUnlockObject(http->entry->p); - http->entry = NULL; - } - if (clientOnlyIfCached(http)) { - clientProcessOnlyIfCachedMiss(http); - return; - } - /* - * Deny loops when running in accelerator/transproxy mode. - */ - 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, null_request_flags); - errorAppendEntry(http->entry, err); - return; - } - assert(http->out.offset == 0); - http->entry = clientDTDCreateStoreEntry(http, r->method, r->flags); - if (http->redirect.status) { - HttpReply *rep = httpReplyCreate(); -#if LOG_TCP_REDIRECTS - http->log_type = LOG_TCP_REDIRECT; #endif - storeReleaseRequest(http->entry->p); - httpRedirectReply(rep, http->redirect.status, http->redirect.location); - httpReplySwapOut(rep, http->entry->p); - httpReplyDestroy(rep); - storeComplete(http->entry->p); - return; - } - if (http->flags.internal) - r->protocol = PROTO_INTERNAL; - fwdStart(http->conn->fd, http->entry, r); - if (EBIT_TEST(http->entry->p->flags, ENTRY_ABORTED)) - debug(33, 0) ("clientProcessMiss: found ENTRY_ABORTED object\n"); - storeClientCopy(http->sc, http->entry->p, - http->out.offset, - http->out.offset, - CLIENT_SOCK_SZ, - memAllocate(MEM_CLIENT_SOCK_BUF), - clientHandleHEADReply, - http); -} static int -clientDTDCachableReply(clientHttpRequest * httpState) +checkAccelOnly(clientHttpRequest * http) { - HttpReply *rep = httpState->entry->p->mem_obj->reply; - HttpHeader *hdr = &rep->header; - const int cc_mask = (rep->cache_control) ? rep->cache_control->mask : 0; - const char *v; - if (EBIT_TEST(httpState->entry->flags, RELEASE_REQUEST)) - return 0; - if (EBIT_TEST(cc_mask, CC_PRIVATE)) + /* return TRUE if someone makes a proxy request to us and + * we are in httpd-accel only mode */ + if (!Config2.Accel.on) return 0; - if (EBIT_TEST(cc_mask, CC_NO_CACHE)) + if (Config.onoff.accel_with_proxy) return 0; - if (EBIT_TEST(cc_mask, CC_NO_STORE)) + if (http->request->protocol == PROTO_CACHEOBJ) return 0; - if (httpState->request->flags.auth) { - /* - * Responses to requests with authorization may be cached - * only if a Cache-Control: public reply header is present. - * RFC 2068, sec 14.9.4 - */ - if (!EBIT_TEST(cc_mask, CC_PUBLIC)) - return 0; - } - /* - * We don't properly deal with Vary features yet, so we can't - * cache these - */ - if (httpHeaderHas(hdr, HDR_VARY)) + if (http->flags.accel) return 0; - /* Pragma: no-cache in _replies_ is not documented in HTTP, - * but servers like "Active Imaging Webcast/2.0" sure do use it */ - if (httpHeaderHas(hdr, HDR_PRAGMA)) { - String s = httpHeaderGetList(hdr, HDR_PRAGMA); - const int no_cache = strListIsMember(&s, "no-cache", ','); - stringClean(&s); - if (no_cache) - return 0; - } + return 1; +} + +#if USE_IDENT +static void +clientIdentDone(const char *ident, void *data) +{ + ConnStateData *conn = data; + if (ident) + xstrncpy(conn->ident, ident, sizeof(conn->ident)); + else + xstrncpy(conn->ident, "-", sizeof(conn->ident)); +} +#endif + +static aclCheck_t * +clientAclChecklistCreate(const acl_access * acl, const clientHttpRequest * http) +{ + aclCheck_t *ch; + ConnStateData *conn = http->conn; + ch = aclChecklistCreate(acl, + http->request, + conn->ident); +#if USE_IDENT /* - * The "multipart/x-mixed-replace" content type is used for - * continuous push replies. These are generally dynamic and - * probably should not be cachable + * hack for ident ACL. It needs to get full addresses, and a + * place to store the ident result on persistent connections... */ - if ((v = httpHeaderGetStr(hdr, HDR_CONTENT_TYPE))) - if (!strncasecmp(v, "multipart/x-mixed-replace", 25)) - return 0; - switch (httpState->entry->p->mem_obj->reply->sline.status) { - /* Responses that are cacheable */ - case HTTP_OK: - case HTTP_NON_AUTHORITATIVE_INFORMATION: - case HTTP_MULTIPLE_CHOICES: - case HTTP_MOVED_PERMANENTLY: - case HTTP_GONE: - /* - * Don't cache objects that need to be refreshed on next request, - * unless we know how to refresh it. - */ - if (!refreshIsCachable(httpState->entry)) - return 0; - /* don't cache objects from peers w/o LMT, Date, or Expires */ - /* check that is it enough to check headers @?@ */ - if (rep->date > -1) - return 1; - else if (rep->last_modified > -1) - return 1; - /* @?@ (here and 302): invalid expires header compiles to squid_curtime */ - else if (rep->expires > -1) - return 1; - else - return 0; - /* NOTREACHED */ - break; - /* Responses that only are cacheable if the server says so */ - case HTTP_MOVED_TEMPORARILY: - if (rep->expires > -1) - return 1; - else - return 0; - /* NOTREACHED */ - break; - /* Errors can be negatively cached */ - case HTTP_NO_CONTENT: - case HTTP_USE_PROXY: - case HTTP_BAD_REQUEST: - case HTTP_FORBIDDEN: - case HTTP_NOT_FOUND: - case HTTP_METHOD_NOT_ALLOWED: - case HTTP_REQUEST_URI_TOO_LARGE: - case HTTP_INTERNAL_SERVER_ERROR: - case HTTP_NOT_IMPLEMENTED: - case HTTP_BAD_GATEWAY: - case HTTP_SERVICE_UNAVAILABLE: - case HTTP_GATEWAY_TIMEOUT: - return -1; - /* NOTREACHED */ - break; - /* Some responses can never be cached */ - case HTTP_PARTIAL_CONTENT: /* Not yet supported */ - case HTTP_SEE_OTHER: - case HTTP_NOT_MODIFIED: - case HTTP_UNAUTHORIZED: - case HTTP_PROXY_AUTHENTICATION_REQUIRED: - case HTTP_INVALID_HEADER: /* Squid header parsing error */ - default: /* Unknown status code */ - return 0; - /* NOTREACHED */ - break; - } - /* NOTREACHED */ + ch->conn = conn; + cbdataLock(ch->conn); +#endif + return ch; } -static void -clientCacheDTDHit(void *data, char *buf, ssize_t size) +void +clientAccessCheck(void *data) { clientHttpRequest *http = data; - StoreEntry *e = http->sc->entry; - MemObject *mem; - request_t *r = http->request; - debug(33, 3) ("clientCacheHit: %s, %d bytes\n", http->uri, (int) size); - if (http->entry == NULL || http->entry->p == NULL) { - memFree(buf, MEM_CLIENT_SOCK_BUF); - debug(33, 3) ("clientCacheHit: request aborted\n"); - return; - } else if (size < 0) { - /* swap in failure */ - memFree(buf, MEM_CLIENT_SOCK_BUF); - debug(33, 3) ("clientCacheHit: swapin failure for %s\n", http->uri); - http->log_type = LOG_TCP_SWAPFAIL_MISS; - if (http->entry->p) { - http->entry = NULL; - storeUnregister(http->sc, e, http); - http->sc = NULL; - storeUnlockObject(e); - } - clientProcessMiss(http); - return; - } - assert(size > 0); - mem = e->mem_obj; - assert(!EBIT_TEST(e->flags, ENTRY_ABORTED)); - if (mem->reply->sline.status == 0) { - /* - * we don't have full reply headers yet; either wait for more or - * punt to clientProcessMiss. - */ - if (e->mem_status == IN_MEMORY || e->store_status == STORE_OK) { - memFree(buf, MEM_CLIENT_SOCK_BUF); - clientProcessMiss(http); - } else if (size == CLIENT_SOCK_SZ && http->out.offset == 0) { - memFree(buf, MEM_CLIENT_SOCK_BUF); - clientProcessMiss(http); - } else { - debug(33, 3) ("clientCacheHit: waiting for HTTP reply headers\n"); - storeClientCopy(http->sc, e, - http->out.offset + size, - http->out.offset, - CLIENT_SOCK_SZ, - buf, - clientCacheDTDHit, - http); - } + if (checkAccelOnly(http)) { + /* deny proxy requests in accel_only mode */ + debug(33, 1) ("clientAccessCheck: proxy request denied in accel_only mode\n"); + clientAccessCheckDone(ACCESS_DENIED, http); return; } - /* - * Got the headers, now grok them - */ - assert(http->log_type == LOG_TCP_HIT); - if (checkNegativeHit(http->entry)) { - http->log_type = LOG_TCP_NEGATIVE_HIT; - clientSendMoreData(data, buf, size); - } else if (r->method == METHOD_HEAD) { - /* - * RFC 2068 seems to indicate there is no "conditional HEAD" - * request. We cannot validate a cached object for a HEAD - * request, nor can we return 304. - */ - if (e->mem_status == IN_MEMORY) - http->log_type = LOG_TCP_MEM_HIT; - clientSendMoreData(data, buf, size); - } else if (r->flags.ims) { - /* - * Handle If-Modified-Since requests from the client - */ - if (mem->reply->sline.status != HTTP_OK) { - debug(33, 4) ("clientCacheHit: Reply code %d != 200\n", - mem->reply->sline.status); - memFree(buf, MEM_CLIENT_SOCK_BUF); - http->log_type = LOG_TCP_MISS; - clientProcessMiss(http); - } else if (modifiedSince(http->entry, http->request)) { - http->log_type = LOG_TCP_IMS_HIT; - clientSendMoreData(data, buf, size); - } else { - time_t timestamp = http->entry->timestamp; - MemBuf mb = httpPacked304Reply(e->mem_obj->reply); - http->log_type = LOG_TCP_IMS_HIT; - memFree(buf, MEM_CLIENT_SOCK_BUF); - storeUnregister(http->sc, e, http); - http->sc = NULL; - storeUnlockObject(e); - http->entry = clientCreateStoreEntry(http, http->request->method, null_request_flags); - /* - * Copy timestamp from the original entry so the 304 - * reply has a meaningful Age: header. - */ - http->entry->timestamp = timestamp; - httpReplyParse(http->entry->p->mem_obj->reply, mb.buf, mb.size); - storeAppend(http->entry->p, mb.buf, mb.size); - memBufClean(&mb); - storeComplete(http->entry->p); - } - } else { - /* - * plain ol' cache hit - */ - if (e->mem_status == IN_MEMORY) - http->log_type = LOG_TCP_MEM_HIT; - else if (Config.onoff.offline) - http->log_type = LOG_TCP_OFFLINE_HIT; - clientSendMoreData(data, buf, size); - } + http->acl_checklist = clientAclChecklistCreate(Config.accessList.http, http); + aclNBCheck(http->acl_checklist, clientAccessCheckDone, http); } -#endif /* * returns true if client specified that the object must come from the cache @@ -628,25 +339,6 @@ EBIT_TEST(r->cache_control->mask, CC_ONLY_IF_CACHED); } -#ifdef DTD -static InstanceEntry * -clientDTDCreateStoreEntry(clientHttpRequest * h, method_t m, request_flags flags) -{ - InstanceEntry *e; - /* - * For erroneous requests, we might not have a h->request, - * so make a fake one. - */ - if (h->request == NULL) - h->request = requestLink(requestCreate(m, PROTO_NONE, null_string)); - e = instanceCreateEntry(h->uri, h->log_uri, flags, m); - h->sc = storeClientListAdd(e->p, h); -#if DELAY_POOLS - delaySetStoreClient(h->sc, delayClient(h->request)); -#endif - return e; -} -#endif #ifdef DSA InstanceEntry * clientCreateStoreEntry(clientHttpRequest * h, method_t m, request_flags flags) @@ -663,6 +355,9 @@ #if DELAY_POOLS delaySetStoreClient(h->sc, delayClient(h->request)); #endif +#ifdef DTD + if (h->request->method != METHOD_GET || h->request->flags.ims || h->request->flags.refresh || h->request->flags.nocache || !h->request->flags.cachable) +#endif storeClientCopy(h->sc, e->p, 0, 0, CLIENT_SOCK_SZ, memAllocate(MEM_CLIENT_SOCK_BUF), clientSendMoreData, h); return e; @@ -1405,14 +1100,6 @@ safe_free(http->al.headers.reply); safe_free(http->redirect.location); stringClean(&http->range_iter.boundary); -#ifdef DTD - if (http->old_entry == NULL && http->old_sc == NULL && http->entry->p->store_status == STORE_PENDING) { - http->old_entry = http->entry; - http->entry = NULL; - http->old_sc = http->sc; - http->sc = NULL; - } -#endif if ((e = http->entry)) { #ifdef DSA /* ymc: @@ -1428,24 +1115,30 @@ * We will have to replace the link from * our InstanceEntry to that old StoreEntry * That's exactly what we are doing here. - */ + */ + if (!EBIT_TEST(e->p->flags, ENTRY_FWD_HDR_WAIT)) { StoreEntry * p = NULL; StoreEntry * op = http->entry->p; p = storeGet(op->hash.key); http->entry = NULL; + if (p == op) storeLockObject(p); storeUnregister(http->sc, e->p, http); - if (p && p != op) { + if (p && p != op && storeValidToSend(p) && !EBIT_TEST(e->flags, RELEASE_REQUEST)) { arrayDelete(op->instances, e); + storeSetPublicKey(e); +#ifdef DTD + e->p->swap_file_sz = -1; + e->p->swap_filen = -1; + e->p->swap_dirn = -1; e->p = p; - if (p->mem_obj == NULL) { - p->mem_obj = op->mem_obj; - op->mem_obj = NULL; - } + storeLockObject(p); +#else + e->p = p; +#endif } - storeUnlockObject(op); + } http->sc = NULL; -// if (EBIT_TEST(e->flags, RELEASE_REQUEST)) -// instanceRelease(e); + storeUnlockObject(e->p); #else http->entry = NULL; storeUnregister(http->sc, e, http); @@ -1461,8 +1154,6 @@ storeUnregister(http->old_sc, e->p, http); http->old_sc = NULL; storeUnlockObject(e->p); -// if (EBIT_TEST(e->flags, RELEASE_REQUEST)) -// instanceRelease(e); #else storeUnregister(http->old_sc, e, http); http->old_sc = NULL; @@ -2124,11 +1815,7 @@ if (checkNegativeHit(e)) { http->log_type = LOG_TCP_NEGATIVE_HIT; clientSendMoreData(data, buf, size); -#ifdef DTD - } else if (r->method == METHOD_HEAD && !r->flags.was_get) { -#else } else if (r->method == METHOD_HEAD) { -#endif /* * RFC 2068 seems to indicate there is no "conditional HEAD" * request. We cannot validate a cached object for a HEAD @@ -2462,9 +2149,6 @@ ssize_t body_size = size; MemBuf mb; ssize_t check_size = 0; -#ifdef DTD - if (http->entry && http->entry->p != http->sc->entry) entry = http->sc->entry; -#endif debug(33, 5) ("clientSendMoreData: %s, %d bytes\n", http->uri, (int) size); assert(size <= CLIENT_SOCK_SZ); assert(http->request != NULL); @@ -2548,11 +2232,7 @@ /* NULL because clientWriteBodyComplete frees it */ return; } -#ifdef DTD - if (http->request->method == METHOD_HEAD && !http->request->flags.was_get) { -#else if (http->request->method == METHOD_HEAD) { -#endif if (rep) { /* do not forward body for HEAD replies */ body_size = 0; @@ -2689,9 +2369,6 @@ StoreEntry *entry = http->entry; #endif int done; -#ifdef DTD - if (http->entry && http->entry->p != http->sc->entry) entry = http->sc->entry; -#endif http->out.size += size; debug(33, 5) ("clientWriteComplete: FD %d, sz %d, err %d, off %d, len %d\n", fd, size, errflag, (int) http->out.offset, entry ? objectLen(entry) : 0); @@ -2734,6 +2411,9 @@ * storage manager. */ if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) debug(33, 0) ("clientWriteComplete 2: ENTRY_ABORTED\n"); +#ifdef DTD + if (http->sc->entry != entry) http->sc->entry = entry; +#endif storeClientCopy(http->sc, entry, http->out.offset, http->out.offset, @@ -2821,6 +2501,18 @@ #ifdef DSA InstanceEntry *e; e = http->entry = instanceGetPublic(http->uri, r->method); + /* + if (e && e->p == NULL) { + EBIT_CLR(e->flags, ENTRY_CACHABLE); + instanceRelease(e); + e = http->entry = NULL; + } + if (e && e->p && e->p->hash.key == NULL) { + EBIT_CLR(e->flags, ENTRY_CACHABLE); + instanceRelease(e); + e = http->entry = NULL; + } + */ if (r->method == METHOD_HEAD && e == NULL) { /* We can generate a HEAD reply from a cached GET object */ e = http->entry = instanceGetPublic(http->uri, METHOD_GET); @@ -3007,14 +2699,6 @@ http); } else { /* MISS CASE, http->log_type is already set! */ -#ifdef DTD - if (http->request->method == METHOD_GET && !http->request->flags.ims && !http->request->flags.refresh && !http->request->flags.nocache && http->request->flags.cachable) { - http->request->flags.was_get = 1; - http->request->method = METHOD_HEAD; - clientProcessDTD(http); - } - else -#endif clientProcessMiss(http); } } @@ -3093,6 +2777,29 @@ } if (http->flags.internal) r->protocol = PROTO_INTERNAL; +#ifdef DTD + if (http->request->method == METHOD_GET && !http->request->flags.ims && !http->request->flags.refresh && !http->request->flags.nocache && http->request->flags.cachable) { + http->request->flags.was_get = 1; + http->old_entry = http->entry; + http->old_sc = http->sc; + http->entry = instanceCreateEntry(url, http->log_uri, http->request->flags, http->request->method); + http->request->method = METHOD_HEAD; + http->sc = storeClientListAdd(http->entry->p, http); + http->request->lastmod = http->old_entry->lastmod; + http->out.offset = 0; + fwdStart(http->conn->fd, http->entry, r); + if (EBIT_TEST(http->entry->p->flags, ENTRY_ABORTED)) + debug(33, 0) ("clientProcessMiss: found ENTRY_ABORTED object\n"); + storeClientCopy(http->sc, http->entry->p, + http->out.offset, + http->out.offset, + CLIENT_SOCK_SZ, + memAllocate(MEM_CLIENT_SOCK_BUF), + clientHandleHEADReply, + http); + } + else +#endif fwdStart(http->conn->fd, http->entry, r); } @@ -3807,9 +3514,6 @@ int sendlen; if (entry == NULL) return 0; -#ifdef DTD - if (http->entry->p != http->sc->entry) entry = http->sc->entry; -#endif /* * For now, 'done_copying' is used for special cases like * Range and HEAD requests. Index: squid/src/forward.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/forward.c,v retrieving revision 1.4.4.1.10.5.2.4 retrieving revision 1.4.4.1.10.5.2.5 diff -u -r1.4.4.1.10.5.2.4 -r1.4.4.1.10.5.2.5 --- squid/src/forward.c 1 Jan 2003 22:40:51 -0000 1.4.4.1.10.5.2.4 +++ squid/src/forward.c 11 Mar 2004 06:02:57 -0000 1.4.4.1.10.5.2.5 @@ -1,6 +1,6 @@ /* - * $Id: forward.c,v 1.4.4.1.10.5.2.4 2003/01/01 22:40:51 ymc Exp $ + * $Id: forward.c,v 1.4.4.1.10.5.2.5 2004/03/11 06:02:57 ymc Exp $ * * DEBUG: section 17 Request Forwarding * AUTHOR: Duane Wessels @@ -17,8 +17,10 @@ * incorporates software developed and/or copyrighted by other * sources; see the CREDITS file for full details. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * This program is free software; you can redistribute it and/or +modify + * it under the terms of the GNU General Public License as published +by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * @@ -29,7 +31,8 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, +USA. * */ @@ -51,7 +54,8 @@ static STABH fwdAbort; #define MAX_FWD_STATS_IDX 9 -static int FwdReplyCodes[MAX_FWD_STATS_IDX + 1][HTTP_INVALID_HEADER + 1]; +static int FwdReplyCodes[MAX_FWD_STATS_IDX + 1][HTTP_INVALID_HEADER + +1]; #if WIP_FWD_LOG static void fwdLog(FwdState * fwdState); @@ -69,6 +73,10 @@ static void fwdStateFree(FwdState * fwdState) { +#ifdef DTD + const char *host; + unsigned short port; +#endif #ifdef DSA StoreEntry *e = fwdState->entry->p; #else @@ -101,10 +109,33 @@ if (storePendingNClients(e) > 0) assert(!EBIT_TEST(e->flags, ENTRY_FWD_HDR_WAIT)); fwdServersFree(&fwdState->servers); +#ifdef DTD + host = fwdState->request->host; + port = fwdState->request->port; +#endif requestUnlink(fwdState->request); fwdState->request = NULL; if (fwdState->err) errorStateFree(fwdState->err); +#ifdef DTD + if (fwdState->entry && !EBIT_TEST(fwdState->entry->p->flags, +ENTRY_FWD_HDR_WAIT) && !EBIT_TEST(fwdState->entry->flags, RELEASE_REQUEST)) +{ + StoreEntry * p = NULL; + StoreEntry * op = fwdState->entry->p; + p = storeGet(op->hash.key); + if (p == op) storeLockObject(p); + if (p && p != op && storeValidToSend(p)) { + arrayDelete(op->instances, fwdState->entry); + fwdState->entry->p->swap_file_sz = -1; + fwdState->entry->p->swap_filen = -1; + fwdState->entry->p->swap_dirn = -1; + fwdState->entry->p = p; + storeSetPublicKey(fwdState->entry); + storeLockObject(p); + } + } +#endif storeUnregisterAbort(e); storeUnlockObject(e); fwdState->entry = NULL; @@ -113,7 +144,11 @@ comm_remove_close_handler(sfd, fwdServerClosed, fwdState); fwdState->server_fd = -1; debug(17, 3) ("fwdStateFree: closing FD %d\n", sfd); +#ifdef DTD + pconnPush(sfd, host, port); +#else comm_close(sfd); +#endif } cbdataFree(fwdState); } @@ -148,9 +183,11 @@ { FwdState *fwdState = data; #ifdef DSA - debug(17, 2) ("fwdServerClosed: FD %d %s\n", fd, storeUrl(fwdState->entry->p)); + debug(17, 2) ("fwdServerClosed: FD %d %s\n", fd, +storeUrl(fwdState->entry->p)); #else - debug(17, 2) ("fwdServerClosed: FD %d %s\n", fd, storeUrl(fwdState->entry)); + debug(17, 2) ("fwdServerClosed: FD %d %s\n", fd, +storeUrl(fwdState->entry)); #endif assert(fwdState->server_fd == fd); fwdState->server_fd = -1; @@ -225,14 +262,18 @@ comm_close(server_fd); } else { #ifdef DSA - debug(17, 3) ("fwdConnectDone: FD %d: '%s'\n", server_fd, storeUrl(fwdState->entry->p)); + debug(17, 3) ("fwdConnectDone: FD %d: '%s'\n", server_fd, +storeUrl(fwdState->entry->p)); #else - debug(17, 3) ("fwdConnectDone: FD %d: '%s'\n", server_fd, storeUrl(fwdState->entry)); + debug(17, 3) ("fwdConnectDone: FD %d: '%s'\n", server_fd, +storeUrl(fwdState->entry)); #endif if (fs->peer) - hierarchyNote(&fwdState->request->hier, fs->code, fs->peer->host); + hierarchyNote(&fwdState->request->hier, fs->code, +fs->peer->host); else if (Config.onoff.log_ip_on_direct) - hierarchyNote(&fwdState->request->hier, fs->code, fd_table[server_fd].ipaddr); + hierarchyNote(&fwdState->request->hier, fs->code, +fd_table[server_fd].ipaddr); else hierarchyNote(&fwdState->request->hier, fs->code, request->host); #ifdef DSA @@ -258,7 +299,8 @@ StoreEntry *entry = fwdState->entry; #endif ErrorState *err; - debug(17, 2) ("fwdConnectTimeout: FD %d: '%s'\n", fd, storeUrl(entry)); + debug(17, 2) ("fwdConnectTimeout: FD %d: '%s'\n", fd, +storeUrl(entry)); assert(fd == fwdState->server_fd); if (entry->mem_obj->inmem_hi == 0) { err = errorCon(ERR_CONNECT_FAIL, HTTP_GATEWAY_TIMEOUT); @@ -349,9 +391,11 @@ { FwdState *fwdState = data; #ifdef DSA - debug(17, 3) ("fwdStartComplete: %s\n", storeUrl(fwdState->entry->p)); + debug(17, 3) ("fwdStartComplete: %s\n", +storeUrl(fwdState->entry->p)); #else - debug(17, 3) ("fwdStartComplete: %s\n", storeUrl(fwdState->entry)); + debug(17, 3) ("fwdStartComplete: %s\n", +storeUrl(fwdState->entry)); #endif if (servers != NULL) { fwdState->servers = servers; @@ -402,7 +446,8 @@ #endif netdbPingSite(request->host); /* - * Assert that server_fd is set. This is to guarantee that fwdState + * Assert that server_fd is set. This is to guarantee that +fwdState * is attached to something and will be deallocated when server_fd * is closed. */ @@ -472,8 +517,10 @@ assert(e->mem_obj->chksum == url_checksum(e->mem_obj->url)); #endif debug(17, 3) ("fwdReforward: %s?\n", storeUrl(e)); -#ifdef DTD - if (fwdState->request->flags.was_get == 1) { +#ifdef DTD + if (fwdState->entry->p->mem_obj->swapout.sio == NULL && +fwdState->request->flags.was_get == 1 && fwdState->request->method == +METHOD_HEAD) { return 1; } #endif @@ -528,7 +575,8 @@ */ if (r->client_addr.s_addr != no_addr.s_addr) { /* - * Check if this host is allowed to fetch MISSES from us (miss_access) + * Check if this host is allowed to fetch MISSES from us +(miss_access) */ memset(&ch, '\0', sizeof(aclCheck_t)); ch.src_addr = r->client_addr; @@ -627,7 +675,8 @@ #endif if (EBIT_TEST(e->flags, ENTRY_FWD_HDR_WAIT)) return rc; - if (mem->inmem_hi - storeLowestMemReaderOffset(e) < READ_AHEAD_GAP) + if (mem->inmem_hi - storeLowestMemReaderOffset(e) < +READ_AHEAD_GAP) return rc; return 1; } @@ -675,7 +724,8 @@ fwdUnregister(int fd, FwdState * fwdState) { #ifdef DSA - debug(17, 3) ("fwdUnregister: %s\n", storeUrl(fwdState->entry->p)); + debug(17, 3) ("fwdUnregister: %s\n", +storeUrl(fwdState->entry->p)); #else debug(17, 3) ("fwdUnregister: %s\n", storeUrl(fwdState->entry)); #endif @@ -705,7 +755,8 @@ #if URL_CHECKSUM_DEBUG assert(e->mem_obj->chksum == url_checksum(e->mem_obj->url)); #endif - fwdLogReplyStatus(fwdState->n_tries, e->mem_obj->reply->sline.status); + fwdLogReplyStatus(fwdState->n_tries, +e->mem_obj->reply->sline.status); if (fwdReforward(fwdState)) { debug(17, 3) ("fwdComplete: re-forwarding %d %s\n", e->mem_obj->reply->sline.status, @@ -714,8 +765,9 @@ fwdUnregister(fwdState->server_fd, fwdState); #ifdef DTD if (fwdState->request->flags.was_get == 1) { - fwdState->request->method = METHOD_GET; - fwdState->request->flags.was_get++; + fwdState->request->method = METHOD_GET; + fwdState->request->flags.was_get = 0; + fwdState->request->flags.hierarchical = 1; } #endif storeEntryReset(e); Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.4.4.4.2.8.2.3 retrieving revision 1.4.4.4.2.8.2.4 diff -u -r1.4.4.4.2.8.2.3 -r1.4.4.4.2.8.2.4 --- squid/src/http.c 30 Dec 2002 23:06:41 -0000 1.4.4.4.2.8.2.3 +++ squid/src/http.c 11 Mar 2004 06:02:57 -0000 1.4.4.4.2.8.2.4 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.4.4.4.2.8.2.3 2002/12/30 23:06:41 ymc Exp $ + * $Id: http.c,v 1.4.4.4.2.8.2.4 2004/03/11 06:02:57 ymc Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -123,7 +123,11 @@ #ifdef DSA httpMakePublic(InstanceEntry * entry) { +#ifdef DTD if (!EBIT_TEST(entry->flags, RELEASE_REQUEST) && EBIT_TEST(entry->p->flags, ENTRY_CACHABLE)) +#else + if (EBIT_TEST(entry->p->flags, ENTRY_CACHABLE)) +#endif #else httpMakePublic(StoreEntry * entry) { @@ -567,13 +571,6 @@ else delay_id = delayMostBytesAllowed(entry->mem_obj); #endif -#if 0 - /* if it is a DTD hit, the StoreEntry will be replaced - * by the StoreEntry already in disk. This old StoreEntry - * should have a store_status equals STORE_OK - */ - if (entry->store_status == STORE_OK || EBIT_TEST(entry->flags, RELEASE_REQUEST) || EBIT_TEST(entry->flags, ENTRY_ABORTED)) { -#endif if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) { comm_close(fd); return; @@ -636,11 +633,7 @@ } else if (len == 0) { #ifdef DSA /* Finalize MD5 digest */ -#ifdef DTD - if (EBIT_TEST(entry->flags, KEY_PRIVATE) && !httpState->request->flags.was_get) { -#else - if (EBIT_TEST(entry->flags, KEY_PRIVATE)) { -#endif + if (EBIT_TEST(entry->flags, KEY_PRIVATE)) { cache_key key[MD5_DIGEST_CHARS]; MD5Final(key, &entry->ctx); if (entry->hash.key) { @@ -678,20 +671,13 @@ * If its not a reply that we will re-forward, then * allow the client to get it. */ -#ifdef DTD - if (entry->mem_obj->request->flags.was_get == 0) -#endif if (!fwdReforwardableStatus(s)) EBIT_CLR(entry->flags, ENTRY_FWD_HDR_WAIT); } } #ifdef DSA /* ymc: Update the MD5 digest, skip the header */ -#ifdef DTD - if (EBIT_TEST(entry->flags, KEY_PRIVATE) && !httpState->request->flags.was_get) { -#else if (EBIT_TEST(entry->flags, KEY_PRIVATE)) { -#endif if (entry->mem_obj->inmem_hi >= entry->mem_obj->reply->hdr_sz) MD5Update(&entry->ctx, buf, len); else if (len - entry->mem_obj->reply->hdr_sz > 0) Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.4.4.9.2.4 retrieving revision 1.4.4.9.2.4.2.1 diff -u -r1.4.4.9.2.4 -r1.4.4.9.2.4.2.1 --- squid/src/protos.h 2 Dec 2002 08:11:20 -0000 1.4.4.9.2.4 +++ squid/src/protos.h 11 Mar 2004 06:02:57 -0000 1.4.4.9.2.4.2.1 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.4.4.9.2.4 2002/12/02 08:11:20 ymc Exp $ + * $Id: protos.h,v 1.4.4.9.2.4.2.1 2004/03/11 06:02:57 ymc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -875,6 +875,9 @@ extern void storeFreeMemory(void); extern int expiresMoreThan(time_t, time_t); extern void InvokeHandlers(StoreEntry *); +#ifdef DTD +int storeValidToSend(StoreEntry *); +#endif #ifdef DSA extern void instanceHashInsert(InstanceEntry * e, const cache_key *); extern void storeExpireNow(InstanceEntry *); Index: squid/src/store.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store.c,v retrieving revision 1.4.4.5.6.16.2.2 retrieving revision 1.4.4.5.6.16.2.3 diff -u -r1.4.4.5.6.16.2.2 -r1.4.4.5.6.16.2.3 --- squid/src/store.c 3 Jan 2003 06:33:34 -0000 1.4.4.5.6.16.2.2 +++ squid/src/store.c 11 Mar 2004 06:02:58 -0000 1.4.4.5.6.16.2.3 @@ -1,6 +1,6 @@ /* - * $Id: store.c,v 1.4.4.5.6.16.2.2 2003/01/03 06:33:34 ymc Exp $ + * $Id: store.c,v 1.4.4.5.6.16.2.3 2004/03/11 06:02:58 ymc Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -146,10 +146,8 @@ * prevents httpMakePublic from really setting a public key. */ EBIT_CLR(e->flags, ENTRY_CACHABLE); - if (e->mem_obj && e->instances->count == 0 && e->mem_obj->e) { - EBIT_CLR(e->mem_obj->e->flags, ENTRY_CACHABLE); - instanceRelease(e->mem_obj->e); - } +// if (e->mem_obj && e->mem_obj->e) +// instanceReleaseRequest(e->mem_obj->e); for (i = 0; i < e->instances->count; ++i) instanceReleaseRequest(e->instances->items[i]); } @@ -165,6 +163,13 @@ assert(p->hash.key == NULL); else */ +#ifdef DTD + /* just memFree bogus StoreEntry */ + if (e->flags == 0) { + memFree(e, MEM_STOREENTRY); + return; + } +#endif if (!EBIT_TEST(e->flags, KEY_PRIVATE)) assert(e->hash.key); debug(20, 3) ("storeRelease: Releasing: '%s'\n", storeKeyText(e->hash.key)); @@ -537,11 +542,6 @@ } if (mem != NULL) { mem->id = getKeyCounter(); -#ifdef DTD - if (mem->request && mem->request->flags.was_get == 1) - newkey = storeKeyPrivate(mem->url, METHOD_GET, mem->id); - else -#endif newkey = storeKeyPrivate(mem->url, mem->method, mem->id); } else { newkey = storeKeyPrivate("JUNK", METHOD_NONE, getKeyCounter()); @@ -558,16 +558,9 @@ const cache_key *newkey; int i; MemObject *mem = e->p->mem_obj; -#ifdef DTD - method_t m = mem->method; -#endif if (e->hash.key && !EBIT_TEST(e->flags, KEY_PRIVATE)) return; /* is already public */ assert(mem); -#ifdef DTD - if (mem->request && mem->request->flags.was_get == 1) - mem->method = METHOD_GET; -#endif /* * We can't make RELEASE_REQUEST objects public. Depending on * when RELEASE_REQUEST gets set, we might not be swapping out @@ -597,9 +590,6 @@ } else arrayAppend(e->p->instances, e); instanceHashInsert(e, newkey); -#ifdef DTD - mem->method = m; -#endif if (e->p->swap_filen > -1) storeDirSwapLog(e->p, SWAP_LOG_ADD); } @@ -752,16 +742,15 @@ /* return if the entry is already added */ if (EBIT_TEST(e->flags, ENTRY_CACHABLE)) return; - if (e->p->instances->count > 0) { - for (i = 0; i < e->p->instances->count; ++i) { - if (e->p->instances->items[i] == e) break; - } - if (i == e->p->instances->count) arrayAppend(e->p->instances, e); + if (p->instances->count > 0) { + for (i = 0; i < p->instances->count; ++i) { + if (p->instances->items[i] == e) break; + } + if (i == p->instances->count) arrayAppend(p->instances, e); } else - arrayAppend(e->p->instances, e); + arrayAppend(p->instances, e); EBIT_SET(e->flags, ENTRY_CACHABLE); -// e->p = p; xmemcpy(key, p->hash.key, MD5_DIGEST_CHARS); snprintf(metadata_path, sizeof(metadata_path), "%s/instances/%2.2x/%2.2x/%2.2x%2.2x" @@ -914,7 +903,9 @@ MemObject *mem = e->mem_obj; assert(mem != NULL); assert(len >= 0); +#ifndef DTD assert(e->store_status == STORE_PENDING); +#endif if (len) { debug(20, 5) ("storeAppend: appending %d bytes for '%s'\n", len, @@ -1068,9 +1059,6 @@ } storeReleaseRequest(e); EBIT_CLR(e->flags, ENTRY_CACHABLE); -#ifdef DSA - EBIT_CLR(e->mem_obj->e->flags, ENTRY_CACHABLE); -#endif return 0; } @@ -1113,8 +1101,10 @@ * if we're not STORE_PENDING, then probably we got aborted * and there should be NO clients on this entry */ +#ifndef DTD assert(EBIT_TEST(e->flags, ENTRY_ABORTED)); assert(e->mem_obj->nclients == 0); +#endif return; } e->mem_obj->object_sz = e->mem_obj->inmem_hi; @@ -1256,6 +1246,13 @@ void instanceRelease(InstanceEntry * e) { +#ifdef DTD + /* just memFree bogus StoreEntry */ + if (e->flags == 0) { + memFree(e, MEM_INSTANCEENTRY); + return; + } +#endif debug(20, 3) ("storeRelease: Releasing: '%s'\n", storeKeyText(e->hash.key)); /* If, for any reason we can't discard this object because of an * outstanding request, mark it for pending release */ @@ -1510,6 +1507,22 @@ return (expires > (squid_curtime + when)); } +#ifdef DTD +int +storeValidToSend(StoreEntry * e) +{ + if (EBIT_TEST(e->flags, RELEASE_REQUEST)) + return 0; + if (EBIT_TEST(e->flags, ENTRY_NEGCACHED)) + return 0; + if (EBIT_TEST(e->flags, ENTRY_ABORTED)) + return 0; + if (e->store_status == STORE_PENDING) + return 0; + return 1; +} +#endif + int #ifdef DSA storeEntryValidToSend(InstanceEntry * e) Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.6.2.11.2.5.2.1 retrieving revision 1.6.2.11.2.5.2.2 diff -u -r1.6.2.11.2.5.2.1 -r1.6.2.11.2.5.2.2 --- squid/src/structs.h 24 Dec 2002 04:58:05 -0000 1.6.2.11.2.5.2.1 +++ squid/src/structs.h 11 Mar 2004 06:02:58 -0000 1.6.2.11.2.5.2.2 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.6.2.11.2.5.2.1 2002/12/24 04:58:05 ymc Exp $ + * $Id: structs.h,v 1.6.2.11.2.5.2.2 2004/03/11 06:02:58 ymc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -778,14 +778,14 @@ /* public, readable */ HttpMsgParseState pstate; /* the current parsing state */ -#ifdef DTD - String content_md5; /* Content-MD5 value, needed for DTD */ -#endif /* public, writable, but use httpReply* interfaces when possible */ HttpStatusLine sline; HttpHeader header; HttpBody body; /* for small constant memory-resident text bodies only */ +#ifdef DTD + String content_md5; /* content MD5 value, needed for DTD */ +#endif }; struct _http_state_flags { @@ -1454,7 +1454,7 @@ unsigned int accelerated:1; unsigned int internal:1; #ifdef DTD - unsigned int was_get:1; /* This HEAD request was a GET request */ + unsigned int was_get:1; /* to mark if this is a DTD request in the HEAD phase */ #endif };