--------------------- PatchSet 4991 Date: 2002/09/16 13:27:45 Author: rbcollins Branch: fixrange Tag: (none) Log: Apply Add Parameter Object to Store client callbacks Members: src/StoreClient.h:1.1->1.1.2.1 src/StoreIOResult.h:1.1->1.1.2.1 src/asn.c:1.17->1.17.14.1 src/cbdata.c:1.15->1.15.14.1 src/client_side_reply.c:1.4->1.4.6.1 src/enums.h:1.38->1.38.2.1 src/http.c:1.24->1.24.2.1 src/protos.h:1.61->1.61.2.1 src/stat.c:1.18->1.18.2.1 src/store_client.c:1.14->1.14.2.1 src/store_swapin.c:1.6->1.6.14.1 src/store_swapout.c:1.13->1.13.14.1 src/structs.h:1.68->1.68.2.1 src/typedefs.h:1.28->1.28.2.1 src/urn.c:1.17->1.17.2.1 --- /dev/null Wed Feb 14 01:05:20 2007 +++ squid/src/StoreClient.h Wed Feb 14 01:06:34 2007 @@ -0,0 +1,69 @@ + +/* + * $Id: StoreClient.h,v 1.1.2.1 2002/09/16 13:27:45 rbcollins Exp $ + * + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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. + * + */ + +#ifndef SQUID_STORECLIENT_H +#define SQUID_STORECLIENT_H + +#include "StoreIOResult.h" + +typedef void STCB(void *, char *, ssize_t, StoreIOResult); /* store callback */ + +/* 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 + void *owner; +#endif + StoreEntry *entry; /* ptr to the parent StoreEntry, argh! */ + storeIOState *swapin_sio; + struct { + unsigned int disk_io_pending:1; + unsigned int store_copying:1; + unsigned int copy_event_pending:1; + } flags; +#if DELAY_POOLS + delay_id delay_id; +#endif + dlink_node node; +}; + +extern void storeClientCopyOld(store_client *, StoreEntry *, off_t, off_t, size_t, char *, STCB *, void *); +extern void storeClientCopy(store_client *, StoreEntry *, off_t, size_t, char *, STCB *, void *); + +#endif /* SQUID_STORECLIENT_H */ --- /dev/null Wed Feb 14 01:05:20 2007 +++ squid/src/StoreIOResult.h Wed Feb 14 01:06:34 2007 @@ -0,0 +1,42 @@ + +/* + * $Id: StoreIOResult.h,v 1.1.2.1 2002/09/16 13:27:45 rbcollins Exp $ + * + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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. + * + */ + +#ifndef SQUID_STOREIORESULT_H +#define SQUID_STOREIORESULT_H + +typedef struct _StoreIOResult StoreIOResult; + +struct _StoreIOResult { +}; + +#endif /* SQUID_STOREIORESULT_H */ Index: squid/src/asn.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/asn.c,v retrieving revision 1.17 retrieving revision 1.17.14.1 diff -u -r1.17 -r1.17.14.1 --- squid/src/asn.c 13 Apr 2002 23:09:15 -0000 1.17 +++ squid/src/asn.c 16 Sep 2002 13:27:45 -0000 1.17.14.1 @@ -1,6 +1,6 @@ /* - * $Id: asn.c,v 1.17 2002/04/13 23:09:15 squidadm Exp $ + * $Id: asn.c,v 1.17.14.1 2002/09/16 13:27:45 rbcollins Exp $ * * DEBUG: section 53 AS Number handling * AUTHOR: Duane Wessels, Kostas Anagnostakis @@ -35,6 +35,7 @@ #include "squid.h" #include "radix.h" +#include "StoreClient.h" #define WHOIS_PORT 43 #define AS_REQBUF_SZ 4096 @@ -219,7 +220,7 @@ } static void -asHandleReply(void *data, char *unused_buf, ssize_t retsize) +asHandleReply(void *data, char *unused_buf, ssize_t retsize, StoreIOResult result) { ASState *asState = data; StoreEntry *e = asState->entry; Index: squid/src/cbdata.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/cbdata.c,v retrieving revision 1.15 retrieving revision 1.15.14.1 diff -u -r1.15 -r1.15.14.1 --- squid/src/cbdata.c 13 Apr 2002 23:09:15 -0000 1.15 +++ squid/src/cbdata.c 16 Sep 2002 13:27:45 -0000 1.15.14.1 @@ -1,6 +1,6 @@ /* - * $Id: cbdata.c,v 1.15 2002/04/13 23:09:15 squidadm Exp $ + * $Id: cbdata.c,v 1.15.14.1 2002/09/16 13:27:45 rbcollins Exp $ * * DEBUG: section 45 Callback Data Registry * ORIGINAL AUTHOR: Duane Wessels @@ -138,7 +138,6 @@ CREATE_CBDATA(RemovalPolicy); CREATE_CBDATA(RemovalPolicyWalker); CREATE_CBDATA(RemovalPurgeWalker); - CREATE_CBDATA(store_client); } void * Index: squid/src/client_side_reply.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/client_side_reply.c,v retrieving revision 1.4 retrieving revision 1.4.6.1 diff -u -r1.4 -r1.4.6.1 --- squid/src/client_side_reply.c 15 Sep 2002 21:45:36 -0000 1.4 +++ squid/src/client_side_reply.c 16 Sep 2002 13:27:46 -0000 1.4.6.1 @@ -1,6 +1,6 @@ /* - * $Id: client_side_reply.c,v 1.4 2002/09/15 21:45:36 squidadm Exp $ + * $Id: client_side_reply.c,v 1.4.6.1 2002/09/16 13:27:46 rbcollins Exp $ * * DEBUG: section 88 Client-side Reply Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "StoreClient.h" typedef struct _clientReplyContext { clientHttpRequest *http; @@ -316,7 +317,7 @@ } void -clientHandleIMSReply(void *data, char *buf, ssize_t size) +clientHandleIMSReply(void *data, char *buf, ssize_t size, StoreIOResult result) { clientReplyContext *context = data; clientHttpRequest *http = context->http; @@ -379,6 +380,7 @@ * 304, so put the good one back. First, make sure the old entry * headers have been loaded from disk. */ clientStreamNode *next = context->http->client_stream.head->next->data; + StoreIOResult tempresult; oldentry = http->old_entry; http->logType = LOG_TCP_REFRESH_HIT; if (oldentry->mem_obj->request == NULL) { @@ -402,9 +404,10 @@ entry = http->entry; /* here the data to send is in the next nodes buffers already */ assert(!EBIT_TEST(entry->flags, ENTRY_ABORTED)); - clientSendMoreData(context, next->readbuf, context->reqsize); + clientSendMoreData(context, next->readbuf, context->reqsize, tempresult); } else { /* the client can handle this reply, whatever it is */ + StoreIOResult tempresult; http->logType = LOG_TCP_REFRESH_MISS; if (HTTP_NOT_MODIFIED == mem->reply->sline.status) { httpReplyUpdateOnNotModified(http->old_entry->mem_obj->reply, @@ -418,7 +421,7 @@ context->old_reqsize = 0; assert(!EBIT_TEST(entry->flags, ENTRY_ABORTED)); /* TODO: provide SendMoreData with the ready parsed reply */ - clientSendMoreData(context, context->tempbuf, context->reqsize); + clientSendMoreData(context, context->tempbuf, context->reqsize, tempresult); } } @@ -433,7 +436,7 @@ * clientProcessMiss. */ void -clientCacheHit(void *data, char *buf, ssize_t size) +clientCacheHit(void *data, char *buf, ssize_t size, StoreIOResult result) { clientReplyContext *context = data; clientHttpRequest *http = context->http; @@ -518,17 +521,19 @@ return; } if (storeCheckNegativeHit(e)) { + StoreIOResult tempresult; http->logType = LOG_TCP_NEGATIVE_HIT; - clientSendMoreData(context, buf, size); + clientSendMoreData(context, buf, size, tempresult); } 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. */ + StoreIOResult tempresult; if (e->mem_status == IN_MEMORY) http->logType = LOG_TCP_MEM_HIT; - clientSendMoreData(context, buf, size); + clientSendMoreData(context, buf, size, tempresult); } else if (refreshCheckHTTP(e, r) && !http->flags.internal) { debug(88, 5) ("clientCacheHit: in refreshCheck() block\n"); /* @@ -581,8 +586,9 @@ http->logType = LOG_TCP_MISS; clientProcessMiss(context); } else if (modifiedSince(e, http->request)) { + StoreIOResult tempresult; http->logType = LOG_TCP_IMS_HIT; - clientSendMoreData(context, buf, size); + clientSendMoreData(context, buf, size, tempresult); } else { clientStreamNode *next; time_t timestamp = e->timestamp; @@ -616,11 +622,12 @@ /* * plain ol' cache hit */ + StoreIOResult tempresult; if (e->mem_status == IN_MEMORY) http->logType = LOG_TCP_MEM_HIT; else if (Config.onoff.offline) http->logType = LOG_TCP_OFFLINE_HIT; - clientSendMoreData(context, buf, size); + clientSendMoreData(context, buf, size, tempresult); } } @@ -1355,7 +1362,7 @@ * such, writes processed message to the message recipient */ void -clientSendMoreData(void *data, char *retbuf, ssize_t retsize) +clientSendMoreData(void *data, char *retbuf, ssize_t retsize, StoreIOResult result) { clientReplyContext *context = data; clientHttpRequest *http = context->http; Index: squid/src/enums.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/enums.h,v retrieving revision 1.38 retrieving revision 1.38.2.1 diff -u -r1.38 -r1.38.2.1 --- squid/src/enums.h 15 Sep 2002 11:06:32 -0000 1.38 +++ squid/src/enums.h 16 Sep 2002 13:27:46 -0000 1.38.2.1 @@ -1,6 +1,6 @@ /* - * $Id: enums.h,v 1.38 2002/09/15 11:06:32 rbcollins Exp $ + * $Id: enums.h,v 1.38.2.1 2002/09/16 13:27:46 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -725,7 +725,6 @@ CBDATA_RemovalPolicy, CBDATA_RemovalPolicyWalker, CBDATA_RemovalPurgeWalker, - CBDATA_store_client, CBDATA_FIRST_CUSTOM_TYPE = 1000 } cbdata_type; Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.24 retrieving revision 1.24.2.1 diff -u -r1.24 -r1.24.2.1 --- squid/src/http.c 15 Sep 2002 11:06:32 -0000 1.24 +++ squid/src/http.c 16 Sep 2002 13:27:46 -0000 1.24.2.1 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.24 2002/09/15 11:06:32 rbcollins Exp $ + * $Id: http.c,v 1.24.2.1 2002/09/16 13:27:46 rbcollins Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -210,6 +210,10 @@ storeRelease(pe); } break; + default: + /* Keep GCC happy. The methods above are all mutating HTTP methods + */ + break; } } Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.61 retrieving revision 1.61.2.1 diff -u -r1.61 -r1.61.2.1 --- squid/src/protos.h 15 Sep 2002 11:06:33 -0000 1.61 +++ squid/src/protos.h 16 Sep 2002 13:27:46 -0000 1.61.2.1 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.61 2002/09/15 11:06:33 rbcollins Exp $ + * $Id: protos.h,v 1.61.2.1 2002/09/16 13:27:46 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1064,8 +1064,6 @@ * store_client.c */ extern store_client *storeClientListAdd(StoreEntry * e, void *data); -extern void storeClientCopyOld(store_client *, StoreEntry *, off_t, off_t, size_t, char *, STCB *, void *); -extern void storeClientCopy(store_client *, StoreEntry *, off_t, size_t, char *, STCB *, void *); extern int storeClientCopyPending(store_client *, StoreEntry * e, void *data); extern int storeUnregister(store_client * sc, StoreEntry * e, void *data); extern off_t storeLowestMemReaderOffset(const StoreEntry * entry); Index: squid/src/stat.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/stat.c,v retrieving revision 1.18 retrieving revision 1.18.2.1 diff -u -r1.18 -r1.18.2.1 --- squid/src/stat.c 15 Sep 2002 11:06:33 -0000 1.18 +++ squid/src/stat.c 16 Sep 2002 13:27:47 -0000 1.18.2.1 @@ -1,6 +1,6 @@ /* - * $Id: stat.c,v 1.18 2002/09/15 11:06:33 rbcollins Exp $ + * $Id: stat.c,v 1.18.2.1 2002/09/16 13:27:47 rbcollins Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -33,8 +33,8 @@ * */ - #include "squid.h" +#include "StoreClient.h" #define DEBUG_OPENFD 1 Index: squid/src/store_client.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store_client.c,v retrieving revision 1.14 retrieving revision 1.14.2.1 diff -u -r1.14 -r1.14.2.1 --- squid/src/store_client.c 15 Sep 2002 11:06:33 -0000 1.14 +++ squid/src/store_client.c 16 Sep 2002 13:27:47 -0000 1.14.2.1 @@ -1,6 +1,6 @@ /* - * $Id: store_client.c,v 1.14 2002/09/15 11:06:33 rbcollins Exp $ + * $Id: store_client.c,v 1.14.2.1 2002/09/16 13:27:47 rbcollins Exp $ * * DEBUG: section 20 Storage Manager Client-Side Interface * AUTHOR: Duane Wessels @@ -34,6 +34,9 @@ */ #include "squid.h" +#include "StoreClient.h" + +CBDATA_TYPE(store_client); /* * NOTE: 'Header' refers to the swapfile metadata header. @@ -117,6 +120,7 @@ #endif e->refcount++; mem->nclients++; + CBDATA_INIT_TYPE(store_client); sc = cbdataAlloc(store_client); #if STORE_CLIENT_LIST_DEBUG sc->owner = cbdataReference(data); @@ -143,12 +147,13 @@ STCB *callback = sc->callback; void *cbdata; char *buf = sc->copy_buf; + StoreIOResult result; assert(sc->callback); sc->cmp_offset = sc->copy_offset + sz; sc->callback = NULL; sc->copy_buf = NULL; if (cbdataReferenceValidDone(sc->callback_data, &cbdata)) - callback(cbdata, buf, sz); + callback(cbdata, buf, sz, result); } static void Index: squid/src/store_swapin.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store_swapin.c,v retrieving revision 1.6 retrieving revision 1.6.14.1 diff -u -r1.6 -r1.6.14.1 --- squid/src/store_swapin.c 13 Apr 2002 23:09:17 -0000 1.6 +++ squid/src/store_swapin.c 16 Sep 2002 13:27:48 -0000 1.6.14.1 @@ -1,6 +1,6 @@ /* - * $Id: store_swapin.c,v 1.6 2002/04/13 23:09:17 squidadm Exp $ + * $Id: store_swapin.c,v 1.6.14.1 2002/09/16 13:27:48 rbcollins Exp $ * * DEBUG: section 20 Storage Manager Swapin Functions * AUTHOR: Duane Wessels @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "StoreClient.h" static STIOCB storeSwapInFileClosed; static STFNCB storeSwapInFileNotify; @@ -70,6 +71,7 @@ storeSwapInFileClosed(void *data, int errflag, storeIOState * sio) { store_client *sc = data; + StoreIOResult result; STCB *callback; debug(20, 3) ("storeSwapInFileClosed: sio=%p, errflag=%d\n", sio, errflag); @@ -77,7 +79,7 @@ if ((callback = sc->callback)) { assert(errflag <= 0); sc->callback = NULL; - callback(sc->callback_data, sc->copy_buf, errflag); + callback(sc->callback_data, sc->copy_buf, errflag, result); } statCounter.swap.ins++; } Index: squid/src/store_swapout.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store_swapout.c,v retrieving revision 1.13 retrieving revision 1.13.14.1 diff -u -r1.13 -r1.13.14.1 --- squid/src/store_swapout.c 13 Apr 2002 23:09:17 -0000 1.13 +++ squid/src/store_swapout.c 16 Sep 2002 13:27:48 -0000 1.13.14.1 @@ -1,6 +1,6 @@ /* - * $Id: store_swapout.c,v 1.13 2002/04/13 23:09:17 squidadm Exp $ + * $Id: store_swapout.c,v 1.13.14.1 2002/09/16 13:27:48 rbcollins Exp $ * * DEBUG: section 20 Storage Manager Swapout Functions * AUTHOR: Duane Wessels @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "StoreClient.h" static off_t storeSwapOutObjectBytesOnDisk(const MemObject *); static void storeSwapOutStart(StoreEntry * e); Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.68 retrieving revision 1.68.2.1 diff -u -r1.68 -r1.68.2.1 --- squid/src/structs.h 15 Sep 2002 11:06:33 -0000 1.68 +++ squid/src/structs.h 16 Sep 2002 13:27:48 -0000 1.68.2.1 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.68 2002/09/15 11:06:33 rbcollins Exp $ + * $Id: structs.h,v 1.68.2.1 2002/09/16 13:27:48 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1432,32 +1432,6 @@ int origin_offset; }; -/* 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 - void *owner; -#endif - StoreEntry *entry; /* ptr to the parent StoreEntry, argh! */ - storeIOState *swapin_sio; - struct { - unsigned int disk_io_pending:1; - unsigned int store_copying:1; - unsigned int copy_event_pending:1; - } flags; -#if DELAY_POOLS - delay_id delay_id; -#endif - dlink_node node; -}; - - /* Removal policies */ struct _RemovalPolicyNode { Index: squid/src/typedefs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/typedefs.h,v retrieving revision 1.28 retrieving revision 1.28.2.1 diff -u -r1.28 -r1.28.2.1 --- squid/src/typedefs.h 15 Sep 2002 11:06:34 -0000 1.28 +++ squid/src/typedefs.h 16 Sep 2002 13:27:48 -0000 1.28.2.1 @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.28 2002/09/15 11:06:34 rbcollins Exp $ + * $Id: typedefs.h,v 1.28.2.1 2002/09/16 13:27:48 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -186,7 +186,6 @@ typedef struct _RemovalPurgeWalker RemovalPurgeWalker; typedef struct _RemovalPolicyNode RemovalPolicyNode; typedef struct _RemovalPolicySettings RemovalPolicySettings; - typedef struct _http_version_t http_version_t; #if SQUID_SNMP @@ -245,7 +244,6 @@ typedef void SIH(storeIOState *, void *); /* swap in */ typedef int QS(const void *, const void *); /* qsort */ -typedef void STCB(void *, char *, ssize_t); /* store callback */ typedef void STABH(void *); typedef void ERCB(int fd, void *, size_t); typedef void OBJH(StoreEntry *); Index: squid/src/urn.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/urn.c,v retrieving revision 1.17 retrieving revision 1.17.2.1 diff -u -r1.17 -r1.17.2.1 --- squid/src/urn.c 1 Sep 2002 16:30:43 -0000 1.17 +++ squid/src/urn.c 16 Sep 2002 13:27:48 -0000 1.17.2.1 @@ -1,6 +1,6 @@ /* - * $Id: urn.c,v 1.17 2002/09/01 16:30:43 squidadm Exp $ + * $Id: urn.c,v 1.17.2.1 2002/09/16 13:27:48 rbcollins Exp $ * * DEBUG: section 52 URN Parsing * AUTHOR: Kostas Anagnostakis @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "StoreClient.h" #define URN_REQBUF_SZ 4096 @@ -175,7 +176,7 @@ } static void -urnHandleReply(void *data, char *unused_buf, ssize_t size) +urnHandleReply(void *data, char *unused_buf, ssize_t size, StoreIOResult result) { UrnState *urnState = data; StoreEntry *e = urnState->entry;