--------------------- PatchSet 5054 Date: 2002/09/20 00:28:36 Author: rbcollins Branch: fixrange Tag: (none) Log: give storeClientCopy a StoreIOBuffer internally Members: src/StoreClient.h:1.1.2.5->1.1.2.6 src/client_side.c:1.72.2.42->1.72.2.43 src/client_side_reply.c:1.4.6.19->1.4.6.20 src/stat.c:1.18.2.2->1.18.2.3 src/store_client.c:1.14.2.9->1.14.2.10 src/store_swapin.c:1.6.14.6->1.6.14.7 Index: squid/src/StoreClient.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/StoreClient.h,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -r1.1.2.5 -r1.1.2.6 --- squid/src/StoreClient.h 19 Sep 2002 21:55:42 -0000 1.1.2.5 +++ squid/src/StoreClient.h 20 Sep 2002 00:28:36 -0000 1.1.2.6 @@ -1,6 +1,6 @@ /* - * $Id: StoreClient.h,v 1.1.2.5 2002/09/19 21:55:42 rbcollins Exp $ + * $Id: StoreClient.h,v 1.1.2.6 2002/09/20 00:28:36 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -41,10 +41,7 @@ /* keep track each client receiving data from that particular StoreEntry */ struct _store_client { int type; - off_t copy_offset; off_t cmp_offset; - size_t copy_size; - char *copy_buf; STCB *callback; void *callback_data; #if STORE_CLIENT_LIST_DEBUG @@ -61,8 +58,11 @@ delay_id delay_id; #endif dlink_node node; + /* Below here is private - do no alter outside storeClient calls */ + StoreIOBuffer copyInto; }; extern void storeClientCopy(store_client *, StoreEntry *, StoreIOBuffer, STCB *, void *); +extern void storeClientDumpStats (store_client *thisClient, StoreEntry *output, int clientNumber); #endif /* SQUID_STORECLIENT_H */ Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.72.2.42 retrieving revision 1.72.2.43 diff -u -r1.72.2.42 -r1.72.2.43 --- squid/src/client_side.c 19 Sep 2002 21:55:42 -0000 1.72.2.42 +++ squid/src/client_side.c 20 Sep 2002 00:28:36 -0000 1.72.2.43 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.72.2.42 2002/09/19 21:55:42 rbcollins Exp $ + * $Id: client_side.c,v 1.72.2.43 2002/09/20 00:28:36 rbcollins Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -363,7 +363,7 @@ void clientLogRequest(clientHttpRequest *http) { - if (http->logType) { + if (http->out.size || http->logType) { http->al.icp.opcode = ICP_INVALID; http->al.url = http->log_uri; debug(33, 9) ("clientLogRequest: al.url='%s'\n", http->al.url); @@ -416,9 +416,6 @@ */ } assert(http->logType < LOG_TYPE_MAX); - /* Track regression on the logic for the next call */ - if (http->out.size) - assert (http->logType); clientLogRequest (http); if (request) checkFailureRatio(request->errType, http->al.hier.code); Index: squid/src/client_side_reply.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/client_side_reply.c,v retrieving revision 1.4.6.19 retrieving revision 1.4.6.20 diff -u -r1.4.6.19 -r1.4.6.20 --- squid/src/client_side_reply.c 19 Sep 2002 21:55:43 -0000 1.4.6.19 +++ squid/src/client_side_reply.c 20 Sep 2002 00:28:37 -0000 1.4.6.20 @@ -1,6 +1,6 @@ /* - * $Id: client_side_reply.c,v 1.4.6.19 2002/09/19 21:55:43 rbcollins Exp $ + * $Id: client_side_reply.c,v 1.4.6.20 2002/09/20 00:28:37 rbcollins Exp $ * * DEBUG: section 88 Client-side Reply Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -1403,7 +1403,7 @@ /* This is not valid once we start doing range requests. * Then it becomes context->reqofs == startoffirstrangeentry */ - assert (context->reqofs == 0 || context->flags.headersSent); + assert (context->reqofs == 0 || context->flags.storelogiccomplete); if (buf != result.data) { /* we've got to copy some data */ @@ -1416,7 +1416,7 @@ debug(88, 5) ("clientSendMoreData: %s, %d bytes (%u new bytes)\n", http->uri, (int) size, result.length); - assert(size <= HTTP_REQBUF_SZ); + assert(size <= HTTP_REQBUF_SZ || context->flags.headersSent); assert(http->request != NULL); /* ESI TODO: remove this assert once everything is stable */ assert(http->client_stream.head->data @@ -1448,14 +1448,11 @@ /* clientWriteComplete(fd, NULL, 0, COMM_OK, http); */ return; } - /* FIXME: Adrian says this is a dodgy artifact from the rearrangement of - * HEAD and may not be true for pipelining. - * */ if (context->flags.headersSent != 0) { StoreIOBuffer tempBuffer = EMPTYIOBUFFER; if (result.length == 0) context->flags.complete = 1; - tempBuffer.length = size; + tempBuffer.length = result.length; tempBuffer.data = buf; clientStreamCallback(http->client_stream.head->data, http, NULL, tempBuffer); Index: squid/src/stat.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/stat.c,v retrieving revision 1.18.2.2 retrieving revision 1.18.2.3 diff -u -r1.18.2.2 -r1.18.2.3 --- squid/src/stat.c 19 Sep 2002 08:09:55 -0000 1.18.2.2 +++ squid/src/stat.c 20 Sep 2002 00:28:37 -0000 1.18.2.3 @@ -1,6 +1,6 @@ /* - * $Id: stat.c,v 1.18.2.2 2002/09/19 08:09:55 rbcollins Exp $ + * $Id: stat.c,v 1.18.2.3 2002/09/20 00:28:37 rbcollins Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -258,7 +258,6 @@ { MemObject *mem = e->mem_obj; int i; - struct _store_client *sc; dlink_node *node; storeAppendPrintf(s, "KEY %s\n", storeKeyText(e->hash.key)); if (mem) @@ -281,24 +280,8 @@ if (mem->swapout.sio) storeAppendPrintf(s, "\tswapout: %d bytes written\n", (int) storeOffset(mem->swapout.sio)); - for (i = 0, node = mem->clients.head; node; node = node->next, i++) { - sc = (store_client *) node->data; - if (sc->callback_data == NULL) - continue; - storeAppendPrintf(s, "\tClient #%d, %p\n", i, sc->callback_data); - storeAppendPrintf(s, "\t\tcopy_offset: %d\n", - (int) sc->copy_offset); - storeAppendPrintf(s, "\t\tcopy_size: %d\n", - (int) sc->copy_size); - storeAppendPrintf(s, "\t\tflags:"); - if (sc->flags.disk_io_pending) - storeAppendPrintf(s, " disk_io_pending"); - if (sc->flags.store_copying) - storeAppendPrintf(s, " store_copying"); - if (sc->flags.copy_event_pending) - storeAppendPrintf(s, " copy_event_pending"); - storeAppendPrintf(s, "\n"); - } + for (i = 0, node = mem->clients.head; node; node = node->next, i++) + storeClientDumpStats (node->data, s, i); } storeAppendPrintf(s, "\n"); } Index: squid/src/store_client.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store_client.c,v retrieving revision 1.14.2.9 retrieving revision 1.14.2.10 diff -u -r1.14.2.9 -r1.14.2.10 --- squid/src/store_client.c 19 Sep 2002 21:55:43 -0000 1.14.2.9 +++ squid/src/store_client.c 20 Sep 2002 00:28:37 -0000 1.14.2.10 @@ -1,6 +1,6 @@ /* - * $Id: store_client.c,v 1.14.2.9 2002/09/19 21:55:43 rbcollins Exp $ + * $Id: store_client.c,v 1.14.2.10 2002/09/20 00:28:37 rbcollins Exp $ * * DEBUG: section 20 Storage Manager Client-Side Interface * AUTHOR: Duane Wessels @@ -133,7 +133,6 @@ #if STORE_CLIENT_LIST_DEBUG sc->owner = cbdataReference(data); #endif - sc->copy_offset = 0; sc->cmp_offset = 0; sc->flags.disk_io_pending = 0; sc->entry = e; @@ -154,13 +153,13 @@ { STCB *callback = sc->callback; void *cbdata; - StoreIOBuffer result = {{0}, sz, 0, sc->copy_buf}; + StoreIOBuffer result = {{0}, sz, 0, sc->copyInto.data}; if (sz < 0) result.flags.error = 1; assert(sc->callback); - sc->cmp_offset = sc->copy_offset + sz; + sc->cmp_offset = sc->copyInto.offset + sz; sc->callback = NULL; - sc->copy_buf = NULL; + sc->copyInto.data = NULL; if (cbdataReferenceValidDone(sc->callback_data, &cbdata)) callback(cbdata, result); } @@ -200,9 +199,9 @@ assert(sc->cmp_offset == copyInto.offset); sc->callback = callback; sc->callback_data = cbdataReference(data); - sc->copy_buf = copyInto.data; - sc->copy_size = copyInto.length; - sc->copy_offset = copyInto.offset; + sc->copyInto.data = copyInto.data; + sc->copyInto.length = copyInto.length; + sc->copyInto.offset = copyInto.offset; storeClientCopy2(e, sc); } @@ -224,7 +223,7 @@ return 0; if ((len = objectLen(e)) < 0) return 0; - if (sc->copy_offset < len) + if (sc->copyInto.offset < len) return 0; return 1; } @@ -271,7 +270,7 @@ MemObject *mem = e->mem_obj; size_t sz; - debug(33, 5) ("co: %ld, hi: %ld\n", (long int) sc->copy_offset, (long int) mem->inmem_hi); + debug(33, 5) ("co: %lu, hi: %ld\n", sc->copyInto.offset, (long int) mem->inmem_hi); if (storeClientNoMoreToSend(e, sc)) { /* There is no more to send! */ @@ -279,7 +278,7 @@ return; } /* Check that we actually have data */ - if (e->store_status == STORE_PENDING && sc->copy_offset >= mem->inmem_hi) { + if (e->store_status == STORE_PENDING && sc->copyInto.offset >= mem->inmem_hi) { debug(20, 3) ("storeClientCopy3: Waiting for more\n"); return; } @@ -318,12 +317,12 @@ return; } } - if (sc->copy_offset >= mem->inmem_lo && sc->copy_offset < mem->inmem_hi) { + if (sc->copyInto.offset >= mem->inmem_lo && sc->copyInto.offset < mem->inmem_hi) { /* What the client wants is in memory */ /* Old style */ debug(20, 3) ("storeClientCopy3: Copying normal from memory\n"); - sz = stmemCopy(&mem->data_hdr, sc->copy_offset, sc->copy_buf, - sc->copy_size); + sz = stmemCopy(&mem->data_hdr, sc->copyInto.offset, sc->copyInto.data, + sc->copyInto.length); storeClientCallback(sc, sz); return; } @@ -344,18 +343,18 @@ sc->flags.disk_io_pending = 1; if (mem->swap_hdr_sz == 0) { storeRead(sc->swapin_sio, - sc->copy_buf, - sc->copy_size, + sc->copyInto.data, + sc->copyInto.length, 0, storeClientReadHeader, sc); } else { if (sc->entry->swap_status == SWAPOUT_WRITING) - assert(storeOffset(mem->swapout.sio) > sc->copy_offset + mem->swap_hdr_sz); + assert(storeOffset(mem->swapout.sio) > sc->copyInto.offset + mem->swap_hdr_sz); storeRead(sc->swapin_sio, - sc->copy_buf, - sc->copy_size, - sc->copy_offset + mem->swap_hdr_sz, + sc->copyInto.data, + sc->copyInto.length, + sc->copyInto.offset + mem->swap_hdr_sz, storeClientReadBody, sc); } @@ -370,8 +369,8 @@ 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 && mem->reply->sline.status == 0) - httpReplyParse(mem->reply, sc->copy_buf, headersEnd(sc->copy_buf, len)); + if (sc->copyInto.offset == 0 && len > 0 && mem->reply->sline.status == 0) + httpReplyParse(mem->reply, sc->copyInto.data, headersEnd(sc->copyInto.data, len)); storeClientCallback(sc, len); } @@ -467,17 +466,17 @@ * it to them, otherwise schedule another read. */ body_sz = len - swap_hdr_sz; - if (sc->copy_offset < body_sz) { + if (sc->copyInto.offset < body_sz) { /* * we have (part of) what they want */ - copy_sz = XMIN(sc->copy_size, body_sz); + copy_sz = XMIN(sc->copyInto.length, 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 && mem->reply->sline.status == 0) - httpReplyParse(mem->reply, sc->copy_buf, - headersEnd(sc->copy_buf, copy_sz)); + xmemmove(sc->copyInto.data, sc->copyInto.data + swap_hdr_sz, copy_sz); + if (sc->copyInto.offset == 0 && len > 0 && mem->reply->sline.status == 0) + httpReplyParse(mem->reply, sc->copyInto.data, + headersEnd(sc->copyInto.data, copy_sz)); storeClientCallback(sc, copy_sz); return; } @@ -577,8 +576,8 @@ if (sc->type == STORE_DISK_CLIENT) if (NULL != sc->swapin_sio) continue; - if (sc->copy_offset < lowest) - lowest = sc->copy_offset; + if (sc->copyInto.offset < lowest) + lowest = sc->copyInto.offset; } return lowest; } @@ -683,3 +682,24 @@ statCounter.aborted_requests++; storeAbort(entry); } + +void +storeClientDumpStats (store_client *thisClient, StoreEntry *output, int clientNumber) +{ + if (thisClient->callback_data == NULL) + return; + storeAppendPrintf(output, "\tClient #%d, %p\n", clientNumber, thisClient->callback_data); + storeAppendPrintf(output, "\t\tcopy_offset: %lu\n", + thisClient->copyInto.offset); + storeAppendPrintf(output, "\t\tcopy_size: %d\n", + (int) thisClient->copyInto.length); + storeAppendPrintf(output, "\t\tflags:"); + if (thisClient->flags.disk_io_pending) + storeAppendPrintf(output, " disk_io_pending"); + if (thisClient->flags.store_copying) + storeAppendPrintf(output, " store_copying"); + if (thisClient->flags.copy_event_pending) + storeAppendPrintf(output, " copy_event_pending"); + storeAppendPrintf(output, "\n"); + +} Index: squid/src/store_swapin.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store_swapin.c,v retrieving revision 1.6.14.6 retrieving revision 1.6.14.7 diff -u -r1.6.14.6 -r1.6.14.7 --- squid/src/store_swapin.c 16 Sep 2002 22:58:17 -0000 1.6.14.6 +++ squid/src/store_swapin.c 20 Sep 2002 00:28:37 -0000 1.6.14.7 @@ -1,6 +1,6 @@ /* - * $Id: store_swapin.c,v 1.6.14.6 2002/09/16 22:58:17 rbcollins Exp $ + * $Id: store_swapin.c,v 1.6.14.7 2002/09/20 00:28:37 rbcollins Exp $ * * DEBUG: section 20 Storage Manager Swapin Functions * AUTHOR: Duane Wessels @@ -71,7 +71,7 @@ storeSwapInFileClosed(void *data, int errflag, storeIOState * sio) { store_client *sc = data; - StoreIOBuffer result = {{0},0, 0, sc->copy_buf}; + StoreIOBuffer result = {{0},0, 0, sc->copyInto.data}; STCB *callback; debug(20, 3) ("storeSwapInFileClosed: sio=%p, errflag=%d\n", sio, errflag);