--------------------- PatchSet 8926 Date: 2007/02/18 16:29:57 Author: hno Branch: storework-cutaway Tag: (none) Log: Author: adri Remove the disk client code from the store and store client codebase. Squid will be a memory-only cache whilst the store API is shifted around. Members: src/protos.h:1.133.4.1->1.133.4.2 src/store.c:1.45.4.1->1.45.4.2 src/store_client.c:1.25->1.25.4.1 Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.133.4.1 retrieving revision 1.133.4.2 diff -u -r1.133.4.1 -r1.133.4.2 --- squid/src/protos.h 18 Feb 2007 16:27:36 -0000 1.133.4.1 +++ squid/src/protos.h 18 Feb 2007 16:29:57 -0000 1.133.4.2 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.133.4.1 2007/02/18 16:27:36 hno Exp $ + * $Id: protos.h,v 1.133.4.2 2007/02/18 16:29:57 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -956,8 +956,7 @@ void storeDeferRead(StoreEntry *, int fd); void storeResumeRead(StoreEntry *); void storeResetDefer(StoreEntry *); -extern int memHaveHeaders(const MemObject * mem); - +extern int memHaveHeaders(const MemObject *mem); /* store_modules.c */ extern void storeFsSetup(void); Index: squid/src/store.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store.c,v retrieving revision 1.45.4.1 retrieving revision 1.45.4.2 diff -u -r1.45.4.1 -r1.45.4.2 --- squid/src/store.c 18 Feb 2007 16:27:38 -0000 1.45.4.1 +++ squid/src/store.c 18 Feb 2007 16:29:58 -0000 1.45.4.2 @@ -1,6 +1,6 @@ /* - * $Id: store.c,v 1.45.4.1 2007/02/18 16:27:38 hno Exp $ + * $Id: store.c,v 1.45.4.2 2007/02/18 16:29:58 hno Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -137,7 +137,6 @@ return 1; } - StoreEntry * new_StoreEntry(int mem_obj_flag, const char *url) { @@ -551,7 +550,7 @@ if (EBIT_TEST(e->flags, DELAY_SENDING)) return; InvokeHandlers(e); - storeSwapOut(e); + //storeSwapOut(e); } void @@ -748,7 +747,7 @@ * responses without content length would sometimes get released * in client_side, thinking that the response is incomplete. */ - storeSwapOut(e); + //storeSwapOut(e); InvokeHandlers(e); } @@ -1268,7 +1267,7 @@ if (EBIT_TEST(e->flags, DELAY_SENDING)) { EBIT_CLR(e->flags, DELAY_SENDING); InvokeHandlers(e); - storeSwapOut(e); + //storeSwapOut(e); } } @@ -1446,3 +1445,4 @@ if (e->mem_obj) e->mem_obj->serverfd = -1; } + Index: squid/src/store_client.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store_client.c,v retrieving revision 1.25 retrieving revision 1.25.4.1 diff -u -r1.25 -r1.25.4.1 --- squid/src/store_client.c 26 Jan 2007 02:52:44 -0000 1.25 +++ squid/src/store_client.c 18 Feb 2007 16:29:58 -0000 1.25.4.1 @@ -1,6 +1,6 @@ /* - * $Id: store_client.c,v 1.25 2007/01/26 02:52:44 squidadm Exp $ + * $Id: store_client.c,v 1.25.4.1 2007/02/18 16:29:58 hno Exp $ * * DEBUG: section 20 Storage Manager Client-Side Interface * AUTHOR: Duane Wessels @@ -40,11 +40,8 @@ * 'Body' refers to the swapfile body, which is the full * HTTP reply (including HTTP headers and body). */ -static STRCB storeClientReadBody; -static STRCB storeClientReadHeader; static void storeClientCopy2(StoreEntry * e, store_client * sc); static void storeClientCopy3(StoreEntry * e, store_client * sc); -static void storeClientFileRead(store_client * sc); static EVH storeClientCopyEvent; static store_client_t storeClientType(StoreEntry *); static int CheckQuickAbort2(StoreEntry * entry); @@ -121,6 +118,7 @@ sc->entry = e; storeLockObject(sc->entry); sc->type = storeClientType(e); + assert(sc->type == STORE_MEM_CLIENT); #if STORE_CLIENT_LIST_DEBUG assert(!storeClientListSearch(mem, owner)); sc->owner = owner; @@ -277,40 +275,9 @@ } return; } - /* - * Slight weirdness here. We open a swapin file for any - * STORE_DISK_CLIENT, even if we can copy the requested chunk - * from memory in the next block. We must try to open the - * swapin file before sending any data to the client side. If - * we postpone the open, and then can not open the file later - * on, the client loses big time. Its transfer just gets cut - * off. Better to open it early (while the client side handler - * is clientCacheHit) so that we can fall back to a cache miss - * if needed. - */ - if (STORE_DISK_CLIENT == sc->type && NULL == sc->swapin_sio) { - debug(20, 3) ("storeClientCopy3: Need to open swap in file\n"); - /* gotta open the swapin file */ - if (storeTooManyDiskFilesOpen()) { - /* yuck -- this causes a TCP_SWAPFAIL_MISS on the client side */ - storeClientCallback(sc, -1); - return; - } else if (!sc->flags.disk_io_pending) { - /* Don't set store_io_pending here */ - storeSwapInStart(sc); - if (NULL == sc->swapin_sio) { - storeClientCallback(sc, -1); - return; - } - /* - * If the open succeeds we either copy from memory, or - * schedule a disk read in the next block. - */ - } else { - debug(20, 1) ("WARNING: Averted multiple fd operation (1)\n"); - return; - } - } + /* We're not doing the disk client thing at the moment */ + assert(sc->type == STORE_MEM_CLIENT); + /* We assume at this point its a memory client */ if (sc->copy_offset >= mem->inmem_lo && sc->copy_offset < mem->inmem_hi) { /* What the client wants is in memory */ debug(20, 3) ("storeClientCopy3: Copying from memory\n"); @@ -321,167 +288,12 @@ storeClientCallback(sc, sz); return; } - /* What the client wants is not in memory. Schedule a disk read */ - assert(STORE_DISK_CLIENT == sc->type); - assert(!sc->flags.disk_io_pending); - debug(20, 3) ("storeClientCopy3: reading from STORE\n"); - storeClientFileRead(sc); -} - -static void -storeClientFileRead(store_client * sc) -{ - MemObject *mem = sc->entry->mem_obj; - assert(sc->callback != NULL); - assert(!sc->flags.disk_io_pending); - sc->flags.disk_io_pending = 1; - if (mem->swap_hdr_sz == 0) { - storeRead(sc->swapin_sio, - sc->copy_buf, - sc->copy_size, - 0, - storeClientReadHeader, - sc); - } else { - if (sc->entry->swap_status == SWAPOUT_WRITING) - assert(storeSwapOutObjectBytesOnDisk(mem) > sc->copy_offset); - storeRead(sc->swapin_sio, - sc->copy_buf, - sc->copy_size, - sc->copy_offset + mem->swap_hdr_sz, - storeClientReadBody, - sc); - } -} - -static void -storeClientReadBody(void *data, const char *buf, ssize_t len) -{ - store_client *sc = data; - MemObject *mem = sc->entry->mem_obj; - assert(sc->flags.disk_io_pending); - sc->flags.disk_io_pending = 0; - assert(sc->callback != NULL); - debug(20, 3) ("storeClientReadBody: len %d\n", (int) len); - if (sc->copy_offset == 0 && len > 0 && memHaveHeaders(mem) == 0) - httpReplyParse(mem->reply, sc->copy_buf, headersEnd(sc->copy_buf, len)); - storeClientCallback(sc, len); -} - -static void -storeClientReadHeader(void *data, const char *buf, ssize_t len) -{ - static int md5_mismatches = 0; - store_client *sc = data; - StoreEntry *e = sc->entry; - MemObject *mem = e->mem_obj; - int swap_hdr_sz = 0; - size_t body_sz; - size_t copy_sz; - tlv *tlv_list; - tlv *t; - int swap_object_ok = 1; - assert(sc->flags.disk_io_pending); - sc->flags.disk_io_pending = 0; - assert(sc->callback != NULL); - debug(20, 3) ("storeClientReadHeader: len %d\n", (int) len); - if (len < 0) { - debug(20, 3) ("storeClientReadHeader: %s\n", xstrerror()); - storeClientCallback(sc, len); - return; - } - tlv_list = storeSwapMetaUnpack(buf, &swap_hdr_sz); - if (swap_hdr_sz > len) { - /* oops, bad disk file? */ - debug(20, 1) ("WARNING: swapfile header too small\n"); - storeClientCallback(sc, -1); - return; - } - if (tlv_list == NULL) { - debug(20, 1) ("WARNING: failed to unpack meta data\n"); - storeClientCallback(sc, -1); - return; - } - /* - * Check the meta data and make sure we got the right object. - */ - for (t = tlv_list; t && swap_object_ok; t = t->next) { - switch (t->type) { - case STORE_META_KEY: - assert(t->length == MD5_DIGEST_CHARS); - if (!EBIT_TEST(e->flags, KEY_PRIVATE) && - memcmp(t->value, e->hash.key, MD5_DIGEST_CHARS)) { - debug(20, 2) ("storeClientReadHeader: swapin MD5 mismatch\n"); - debug(20, 2) ("\t%s\n", storeKeyText(t->value)); - debug(20, 2) ("\t%s\n", storeKeyText(e->hash.key)); - if (isPowTen(++md5_mismatches)) - debug(20, 1) ("WARNING: %d swapin MD5 mismatches\n", - md5_mismatches); - swap_object_ok = 0; - } - break; - case STORE_META_URL: - if (NULL == mem->url) - (void) 0; /* can't check */ - else if (0 == strcasecmp(mem->url, t->value)) - (void) 0; /* a match! */ - else { - debug(20, 1) ("storeClientReadHeader: URL mismatch\n"); - debug(20, 1) ("\t{%s} != {%s}\n", (char *) t->value, mem->url); - swap_object_ok = 0; - break; - } - break; - case STORE_META_OBJSIZE: - break; - case STORE_META_STD: - case STORE_META_STD_LFS: - break; - case STORE_META_VARY_HEADERS: - if (mem->vary_headers) { - if (strcmp(mem->vary_headers, t->value) != 0) - swap_object_ok = 0; - } else { - /* Assume the object is OK.. remember the vary request headers */ - mem->vary_headers = xstrdup(t->value); - } - break; - default: - debug(20, 2) ("WARNING: got unused STORE_META type %d\n", t->type); - break; - } - } - storeSwapTLVFree(tlv_list); - if (!swap_object_ok) { - storeClientCallback(sc, -1); - return; - } - mem->swap_hdr_sz = swap_hdr_sz; - mem->object_sz = e->swap_file_sz - swap_hdr_sz; - /* - * If our last read got some data the client wants, then give - * it to them, otherwise schedule another read. - */ - body_sz = len - swap_hdr_sz; - if (sc->copy_offset < body_sz) { - /* - * we have (part of) what they want - */ - copy_sz = XMIN(sc->copy_size, body_sz); - debug(20, 3) ("storeClientReadHeader: copying %d bytes of body\n", - (int) copy_sz); - xmemmove(sc->copy_buf, sc->copy_buf + swap_hdr_sz, copy_sz); - if (sc->copy_offset == 0 && len > 0 && memHaveHeaders(mem) == 0) - httpReplyParse(mem->reply, sc->copy_buf, - headersEnd(sc->copy_buf, copy_sz)); - storeClientCallback(sc, copy_sz); - return; - } - /* - * we don't have what the client wants, but at least we now - * know the swap header size. + /* + * At this point Squid would schedule a disk read; but we're currently + * stripping the old disk code out. So error out if/when we reach this + * spot. */ - storeClientFileRead(sc); + fatal("storeClientCopy3: tried scheduling a disk read with no -disk- support!\n"); } int