--------------------- PatchSet 3378 Date: 2001/11/24 05:51:40 Author: jkay Branch: push Tag: (none) Log: Push branch. Members: src/client_side.c:1.45->1.45.2.1 src/defines.h:1.15->1.15.2.1 src/enums.h:1.27->1.27.2.1 src/globals.h:1.14->1.14.2.1 src/main.c:1.28->1.28.2.1 src/protos.h:1.41->1.41.2.1 src/store.c:1.16->1.16.2.1 src/structs.h:1.47->1.47.2.1 src/typedefs.h:1.25->1.25.2.1 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.45 retrieving revision 1.45.2.1 diff -u -r1.45 -r1.45.2.1 --- squid/src/client_side.c 18 Nov 2001 18:57:17 -0000 1.45 +++ squid/src/client_side.c 24 Nov 2001 05:55:17 -0000 1.45.2.1 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.45 2001/11/18 18:57:17 squidadm Exp $ + * $Id: client_side.c,v 1.45.2.1 2001/11/24 05:55:17 jkay Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -89,7 +89,8 @@ static void clientProcessMiss(clientHttpRequest *); static void clientBuildReplyHeader(clientHttpRequest * http, HttpReply * rep); static clientHttpRequest *parseHttpRequestAbort(ConnStateData * conn, const char *uri); -static clientHttpRequest *parseHttpRequest(ConnStateData *, method_t *, int *, char **, size_t *); +static clientHttpRequest *parseHttpRequest(ConnStateData *, method_t *, + int *, size_t *); static RH clientRedirectDone; static void clientCheckNoCache(clientHttpRequest *); static void clientCheckNoCacheDone(int answer, void *data); @@ -819,6 +820,7 @@ safe_free(http->al.headers.reply); safe_free(http->redirect.location); stringClean(&http->range_iter.boundary); + safe_free(http->hdr_str); if ((e = http->entry)) { http->entry = NULL; storeUnregister(http->sc, e, http); @@ -2299,6 +2301,9 @@ } /* yes, continue */ http->log_type = LOG_TCP_MISS; + } else if (r->method == METHOD_PUT) { + putRecv(http); + return; } else { http->log_type = clientProcessRequest2(http); } @@ -2416,7 +2421,7 @@ */ static clientHttpRequest * parseHttpRequest(ConnStateData * conn, method_t * method_p, int *status, - char **prefix_p, size_t * req_line_sz_p) + size_t * req_line_sz_p) { char *inbuf = NULL; char *mstr = NULL; @@ -2443,7 +2448,6 @@ #endif /* pre-set these values to make aborting simpler */ - *prefix_p = NULL; *method_p = METHOD_NONE; *status = -1; @@ -2546,12 +2550,13 @@ http->start = current_time; http->req_sz = prefix_sz; http->range_iter.boundary = StringNull; - *prefix_p = xmalloc(prefix_sz + 1); - xmemcpy(*prefix_p, conn->in.buf, prefix_sz); - *(*prefix_p + prefix_sz) = '\0'; + http->hdr_str = xmalloc(prefix_sz + 1); + xmemcpy(http->hdr_str, conn->in.buf, prefix_sz); + *(http->hdr_str + prefix_sz) = '\0'; dlinkAdd(http, &http->active, &ClientActiveRequests); - debug(33, 5) ("parseHttpRequest: Request Header is\n%s\n", (*prefix_p) + *req_line_sz_p); + debug(33, 5) ("parseHttpRequest: Request Header is\n%s\n", + http->hdr_str + *req_line_sz_p); #if THIS_VIOLATES_HTTP_SPECS_ON_URL_TRANSFORMATION if ((t = strchr(url, '#'))) /* remove HTML anchors */ *t = '\0'; @@ -2726,7 +2731,6 @@ method_t method; clientHttpRequest *http = NULL; clientHttpRequest **H = NULL; - char *prefix = NULL; ErrorState *err = NULL; fde *F = &fd_table[fd]; int len = conn->in.size - conn->in.offset - 1; @@ -2826,10 +2830,7 @@ http = parseHttpRequest(conn, &method, &parser_return_code, - &prefix, &req_line_sz); - if (!http) - safe_free(prefix); if (http) { assert(http->req_sz > 0); conn->in.offset -= http->req_sz; @@ -2859,7 +2860,6 @@ err->request_hdrs = xstrdup(conn->in.buf); http->entry = clientCreateStoreEntry(http, method, null_request_flags); errorAppendEntry(http->entry, err); - safe_free(prefix); break; } if ((request = urlParse(method, http->uri)) == NULL) { @@ -2870,14 +2870,13 @@ http->al.http.code = err->http_status; http->entry = clientCreateStoreEntry(http, method, null_request_flags); errorAppendEntry(http->entry, err); - safe_free(prefix); break; } else { /* compile headers */ /* we should skip request line! */ - if (!httpRequestParseHeader(request, prefix + req_line_sz)) + if (!httpRequestParseHeader(request, http->hdr_str + req_line_sz)) debug(33, 1) ("Failed to parse request headers: %s\n%s\n", - http->uri, prefix); + http->uri, http->hdr_str); /* continue anyway? */ } request->flags.accelerated = http->flags.accel; @@ -2899,7 +2898,6 @@ request->content_length = httpHeaderGetInt(&request->header, HDR_CONTENT_LENGTH); request->flags.internal = http->flags.internal; - safe_free(prefix); safe_free(http->log_uri); http->log_uri = xstrdup(urlCanonicalClean(request)); request->client_addr = conn->peer.sin_addr; Index: squid/src/defines.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/defines.h,v retrieving revision 1.15 retrieving revision 1.15.2.1 diff -u -r1.15 -r1.15.2.1 --- squid/src/defines.h 18 Nov 2001 01:15:42 -0000 1.15 +++ squid/src/defines.h 24 Nov 2001 05:53:17 -0000 1.15.2.1 @@ -1,6 +1,6 @@ /* - * $Id: defines.h,v 1.15 2001/11/18 01:15:42 squidadm Exp $ + * $Id: defines.h,v 1.15.2.1 2001/11/24 05:53:17 jkay Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -296,4 +296,59 @@ #define O_BINARY 0 #endif +/* put.c */ +#define P_ACTIVE(p) ((p)->flags.connected | (p)->flags.connecting) + + +#if USE_HINT_CACHE +/* Hint Cache Interface */ + +#define HINT_CACHE_VERSION "1.0" /* Protocol version */ + +/* Returns true iff the hint cache is in operation. */ +#define HINT_CACHE_ACTIVE() (HCDisk != NULL) + +#define URLKEY_COMPARE(k1, k2) ((k1).key - (k2).key) + +/* Hint Cache Primitives */ +#define HCE_VALID(hce) ((hce)->ipaddr.s_addr != INADDR_ANY &&\ + URLKEY_COMPARE((hce)->key, INVALID_URL_KEY)) +#define HCE_INVALIDATE(hce) ((hce)->ipaddr.s_addr = INADDR_ANY, \ + (hce)->key = INVALID_URL_KEY); + + +/* Hint protocol event types */ +#define HC_InvalToParent 1 +#define HC_InvalToChild 2 +#define HC_InformToParent 3 +#define HC_InformToChild 4 +#define HC_NewVersion 5 +#define HC_Join 6 +#define HC_Leave 7 +#define HC_Ignore 8 /* Message supressed. Ignore it. */ +#define HC_NotChild 9 /* "I am not your child" */ +#define HC_Error 10 + +/* Smallest an HCUPDATE can be (e.g., length of a v1 update). */ +#define HCU_MINLEN 24 + +/* Hint Cache Disk */ +#define HCD_VERSION 2 + +#define HCD_PREFETCH_THRESH 3 + +#endif /* USE_HINT_CACHE */ + + +/* CygWin & Windows NT Port */ +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) +#define _WIN_OS_UNKNOWN 0 +#define _WIN_OS_WIN32S 1 +#define _WIN_OS_WIN95 2 +#define _WIN_OS_WIN98 3 +#define _WIN_OS_WINNT 4 +#define _WIN_OS_WIN2K 5 +#define _WIN_OS_WINXP 6 +#endif + #endif /* SQUID_DEFINES_H */ Index: squid/src/enums.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/enums.h,v retrieving revision 1.27 retrieving revision 1.27.2.1 diff -u -r1.27 -r1.27.2.1 --- squid/src/enums.h 18 Nov 2001 01:15:42 -0000 1.27 +++ squid/src/enums.h 24 Nov 2001 05:53:17 -0000 1.27.2.1 @@ -1,6 +1,6 @@ /* - * $Id: enums.h,v 1.27 2001/11/18 01:15:42 squidadm Exp $ + * $Id: enums.h,v 1.27.2.1 2001/11/24 05:53:17 jkay Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -48,6 +48,7 @@ LOG_TCP_MEM_HIT, LOG_TCP_DENIED, LOG_TCP_OFFLINE_HIT, + LOG_TCP_PUT, #if LOG_TCP_REDIRECTS LOG_TCP_REDIRECT, #endif @@ -56,6 +57,7 @@ LOG_UDP_DENIED, LOG_UDP_INVALID, LOG_UDP_MISS_NOFETCH, + LOG_UDP_PUT, LOG_ICP_QUERY, LOG_TYPE_MAX } log_type; @@ -729,6 +731,13 @@ VARY_CANCEL }; +#if USE_HINT_CACHE +enum HintCacheNet_State {HC_uninitialized, HC_filling, HC_full, HC_destroyed}; + +typedef enum HintCacheNeighborActionE {NEIGHBOR_ADD, NEIGHBOR_REMOVE} NeighborAction; + +#endif /* USE_HINT_CACHE */ + /* CygWin & Windows NT Port */ #if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) /* Index: squid/src/globals.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/globals.h,v retrieving revision 1.14 retrieving revision 1.14.2.1 diff -u -r1.14 -r1.14.2.1 --- squid/src/globals.h 18 Oct 2001 20:52:11 -0000 1.14 +++ squid/src/globals.h 24 Nov 2001 05:53:17 -0000 1.14.2.1 @@ -1,6 +1,6 @@ /* - * $Id: globals.h,v 1.14 2001/10/18 20:52:11 squidadm Exp $ + * $Id: globals.h,v 1.14.2.1 2001/11/24 05:53:17 jkay Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -157,6 +157,10 @@ extern RemovalPolicy *mem_policy; extern hash_table *proxy_auth_username_cache; /* NULL */ extern int incoming_sockets_accepted; +#if USE_HINT_CACHE +extern const URLKey INVALID_URL_KEY; +extern HintCacheDisk *HCDisk; +#endif #if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) extern unsigned int WIN32_OS_version; /* 0 */ extern char *WIN32_OS_string; Index: squid/src/main.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/main.c,v retrieving revision 1.28 retrieving revision 1.28.2.1 diff -u -r1.28 -r1.28.2.1 --- squid/src/main.c 24 Oct 2001 09:42:13 -0000 1.28 +++ squid/src/main.c 24 Nov 2001 05:53:17 -0000 1.28.2.1 @@ -1,6 +1,6 @@ /* - * $Id: main.c,v 1.28 2001/10/24 09:42:13 squidadm Exp $ + * $Id: main.c,v 1.28.2.1 2001/11/24 05:53:17 jkay Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -518,6 +518,9 @@ #if DELAY_POOLS delayPoolsInit(); #endif +#if USE_HINT_CACHE + hintCacheInit(); +#endif fwdInit(); } #if USE_WCCP Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.41 retrieving revision 1.41.2.1 diff -u -r1.41 -r1.41.2.1 --- squid/src/protos.h 13 Nov 2001 22:19:33 -0000 1.41 +++ squid/src/protos.h 24 Nov 2001 05:53:17 -0000 1.41.2.1 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.41 2001/11/13 22:19:33 squidadm Exp $ + * $Id: protos.h,v 1.41.2.1 2001/11/24 05:53:17 jkay Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -313,6 +313,9 @@ extern int httpAnonHdrDenied(http_hdr_type hdr_id); extern void httpBuildRequestHeader(request_t *, request_t *, StoreEntry *, HttpHeader *, int, http_state_flags); extern void httpBuildVersion(http_version_t * version, unsigned int major, unsigned int minor); +extern HttpStateData *httpStateFromClient(clientHttpRequest *http); +extern PF httpReadReply; +extern PF httpStateFree; extern const char *httpMakeVaryMark(request_t * request, HttpReply * reply); /* ETag */ @@ -1105,7 +1108,7 @@ extern char *url_convert_hex(char *org_url, int allocate); extern char *url_escape(const char *url); -extern protocol_t urlParseProtocol(const char *); +extern protocol_t urlParseProtocol(const char *, int *); extern method_t urlParseMethod(const char *); extern void urlInitialize(void); extern request_t *urlParse(method_t, char *); @@ -1293,6 +1296,22 @@ extern void logfilePrintf(va_alist); #endif +/* put.c */ +void putRecv(clientHttpRequest *); +Pusher *putSend(StoreEntry *, struct sockaddr_in *, PF, void *, + int dodist); +void putSendDone(int fd, Pusher *p); +void putReplyAndClose(int, StoreEntry *); + +/* dist.c */ +extern Updatee *distNewUpdatee(StoreEntry *entry, + struct in_addr host, int dport); +extern void distEntryUpdate(StoreEntry *e, request_t *req, + struct sockaddr_in *peer); +extern void distDelUpdatees(Updatee *u); +extern char *distifyUrl(char *url); +extern void distInputDone(StoreEntry *); + /* * Removal Policies */ @@ -1317,6 +1336,150 @@ */ extern StatCounters *snmpStatGet(int); + +#if USE_HINT_CACHE +/* Hint Cache Interface */ +/* open existing cache; return nonzero on error */ +int hintCacheInit(); +void hintCacheCreate(); /* create new cache */ +void hintCacheDestroy(); +void hintCacheInformLocalCopy(char *url, StoreEntry *); /* tell hierarchy I have a copy */ +void hintCacheInvalLocalCopy(StoreEntry *); /* say I don't have a copy */ +int hintCacheActive(); /* Ask hint cache if it is operational. */ +struct sockaddr_in *hintCachefindNearest(char *url, struct sockaddr_in *); + +/* Hint Cache Primitives */; +void URLKeyInit (URLKey *key, char *url); +void NetURLKeyInit(Net_URLKey *mungedKey, URLKey *key); +void NetURLKeyLocalFormat(Net_URLKey *mungedKey, URLKey *key); + +void NodeKeyInit(NodeKey *k, const struct sockaddr_in *addrP); +int NodeKeyCompare(const NodeKey *k1, const NodeKey *k2); +struct sockaddr_in NodeKeyGetAddr(const NodeKey *k); +GenericKey NodeKKKey(const struct sockaddr_in *addrP); + +void hintCacheEntryInit(HintCacheEntry *, URLKey, struct sockaddr_in *, + unsigned int mtime); +int hintCacheEntryCompare(HintCacheEntry *e1, HintCacheEntry *e2); +void hintCacheEntryInitNet(Net_HintCacheEntry *mungedEntry, HintCacheEntry *entry); +void hintCacheEntryLocalFormatNet(Net_HintCacheEntry *mungedEntry, HintCacheEntry *entry); + +int hintCacheUpdateCompare(HintCacheUpdate *u1, HintCacheUpdate *u2); +void hintCacheUpdateInit(HintCacheUpdate *, int action, HintCacheEntry *, int hopcount); + +void hintCacheUpdateInitNet(Net_HintCacheUpdate *mungedUpdate, HintCacheUpdate *update); +void hintCacheUpdateLocalFormatNet(Net_HintCacheUpdate *mungedUpdate, HintCacheUpdate *update); + +/* Hint Cache Disk */ +void hintCacheDiskInit(HintCacheDisk *d, char *diskPath); +void hintCacheDiskClose(HintCacheDisk *d); +void hintCacheDiskCreateFile(char *hcPath, int size, int associativity); +void hintCacheDiskInformLocal(HintCacheDisk *d, URLKey key, unsigned mtime); +void hintCacheDiskInvalLocal(HintCacheDisk *d, URLKey key, unsigned mtime); +void hintCacheDiskPrefetch(HintCacheDisk *d, HintCacheUpdate *uArray, int nupdates); +int hintCacheDiskNetInvalRecord(HintCacheDisk *d, HintCacheEntry *target, HintCacheEntry *survivor); +int hintCacheDiskUpdateIfCloser(HintCacheDisk *d, HintCacheEntry *new); +int hintCacheDiskFindNearest(HintCacheDisk *d, URLKey key, HintCacheEntry *match); +void hintCacheDiskDeleteHintCache(); + +long long unsigned hintCacheEndian_llNetToMachine(long long unsigned net); +long long unsigned hintCacheEndian_llMachineToNet(long long unsigned mach); +void hintCacheEndian_selfTest(void); + +void hintCacheInitNet(HintCacheNet *n); +int hintCacheNet_IsInitialized(void); + void hintCacheNet_Destroy(HintCacheNet *n); +void hintCacheNet_Enqueue(HintCacheNet *, int action, + HintCacheEntry *, int hopcount); +int hintCacheNet_bytesReady(HintCacheNet *n); +void hintCacheNet_Complete(HintCacheNet *n); +void hintCacheNet_Done(HintCacheNet *n); +void hintCacheNet_SendTo(HintCacheNet *, struct sockaddr_in *); +void hintCacheNet_SendJoin(); +void hintCacheNet_DataArrives(char *data, int len, HintCacheNetHeader *hdr, + struct sockaddr_in *source); +void hintCacheNet_SetTestMode(HintCacheNet *n); +int hintCacheNet_GetTestCount(HintCacheNet *n); + +void hintCacheProp_LocalAction(StoreEntry *, int action); +void hintCacheProp_HandleInvalToChild(HintCacheUpdate *update, + struct sockaddr_in *src, int local); +void hintCacheProp_HandleInformToChild(HintCacheUpdate *update, + struct sockaddr_in *src, int local) ; +void hintCacheProp_HandleInvalToParent(HintCacheUpdate *update, + struct sockaddr_in *src, int local); +void hintCacheProp_HandleInformToParent(HintCacheUpdate *update, + struct sockaddr_in *src, int local); + +void hintCacheNodelist_Init(); /* constructor */ +void hintCacheNodelist_Destroy(); /* destructor */ +void hintCacheNodelist_SelfTest(); +void hintCacheNodelist_LocalJoin(); /* I do a join */ +void hintCacheNodelist_LocalLeave(); /* I do a leave */ +int hintCacheNodelist_myStatus(); /* Am I in or out? */ +void hintCacheNodelist_NetJoin(struct sockaddr_in *sin, int hops, long long timeNS); +void hintCacheNodelist_NetLeave(struct sockaddr_in *sin, int hops, long long timeNS); +void hintCacheNodeList_IterStart(HintCacheNodeListIter *iter); +int hintCacheNodeList_IterCheck(HintCacheNodeListIter iter); +void hintCacheNodeList_IterNext(HintCacheNodeListIter *iter); +int hintCacheNodeList_IterGetAddr(HintCacheNodeListIter iter, + struct sockaddr_in *ret); +void hintCacheNodelist_addMembershipNeighbor(struct sockaddr_in *neighbor); +void hintCacheNodelist_rmMembershipNeighbor(struct sockaddr_in *neighbor); + +void hintCacheHier_updateMembershipNeighbor(struct sockaddr_in *neighbor, + NeighborAction); +void hintCacheHier_Init(); +void hintCacheHier_Destroy(); +int hintCacheHier_compareDistanceFromMe(struct in_addr new, struct in_addr old); +void hintCacheHier_newNode(struct sockaddr_in *sin, int hops, long long time); +void hintCacheHier_delNode(struct sockaddr_in *sin, int hops, long long time); +int hintCacheHier_CheckIfParent(URLKey key, struct sockaddr_in *candidate); +int hintCacheHier_CheckIfChild(struct sockaddr_in *candidate); +void hintCacheHier_AddChild(struct sockaddr_in *child); +void hintCacheHier_RemoveChild(struct sockaddr_in *child); +int hintCacheHier_NChildrenQs(); +int hintCacheHier_ChildQIndex(URLKey *key, int iAmRoot, int *amILeaf); +int hintCacheHier_GetChildAddrs(int qIndex, struct sockaddr_in **retAddr); +int hintCacheHier_NParentQs(); +int hintCacheHier_ParentQIndex(URLKey *key, int *amIRoot); +int hintCacheHier_GetParentAddr(int index, struct sockaddr_in *retAddr); +int hintCacheHier_SendToParent(struct sockaddr_in *src, HintCacheUpdate *update, + int msgtype); +int hintCacheHier_SendToSiblings(struct sockaddr_in *src, HintCacheUpdate *update, + int msgtype, int siblingtype); + +#ifdef USE_DYNAMIC_HIERARCHY +/* Plaxton Dynamic Hierarchy algorithm */ +void plaxtonInit(int bitsPerLevel); +void plaxtonDestroy(); +int plaxtonChildQIndex(URLKey *key, int iAmRoot, int *amILeaf); +int plaxtonNChildrenQsI(); +int plaxtonGetChildAddrs(int qIndex, struct sockaddr_in **retAddrAP); +int plaxtonNParentQs(); +int plaxtonParentQIndex(URLKey *key, int *amIRoot); +int plaxtonGetParentAddr(int index, struct sockaddr_in *retAddr); +/* + * Callbacks when nodes added/removed/change distance + */ +void plaxtonAddNode(struct sockaddr_in *newNode); +void plaxtonRemoveNode(struct sockaddr_in *goneNode); +void plaxtonChangeDistance(struct sockaddr_in *changeDistNode); +int plaxtonCheckIfParent(URLKey key, struct sockaddr_in *candidate); +int plaxtonCheckIfChild(struct sockaddr_in *candidate); +void plaxtonAddChild(struct sockaddr_in *child); +void plaxtonRemoveChild(struct sockaddr_in *child); +int plaxtonMatchBits(GenericKey k1, GenericKey k2); +GenericKey plaxtonMyNodeKey(); + +extern int Plaxton_BucketsPerLevel; +extern HintCacheNet *Plaxton_parentOutgoingA; +extern HintCacheNet *Plaxton_childrenOutgoingA; +extern HintCacheNet *Plaxton_neighborsOutgoing; +#endif /* USE_DYNAMIC_HIERARCHY / Plaxton algorithm */ + +#endif /* USE_HINT_CACHE */ + /* Vary support functions */ int varyEvaluateMatch(StoreEntry * entry, request_t * req); Index: squid/src/store.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store.c,v retrieving revision 1.16 retrieving revision 1.16.2.1 diff -u -r1.16 -r1.16.2.1 --- squid/src/store.c 24 Oct 2001 09:42:13 -0000 1.16 +++ squid/src/store.c 24 Nov 2001 05:51:40 -0000 1.16.2.1 @@ -1,6 +1,6 @@ /* - * $Id: store.c,v 1.16 2001/10/24 09:42:13 squidadm Exp $ + * $Id: store.c,v 1.16.2.1 2001/11/24 05:51:40 jkay Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -179,6 +179,8 @@ if (e->mem_obj) destroy_MemObject(e); storeHashDelete(e); + if (e->updatees) + distDelUpdatees(e->updatees); assert(e->hash.key == NULL); memFree(e, MEM_STOREENTRY); } @@ -707,6 +709,9 @@ assert(e->mem_obj->nclients == 0); return; } +#if USE_HINT_CACHE + hintCacheInformLocalCopy(e->mem_obj->url, e); +#endif e->mem_obj->object_sz = e->mem_obj->inmem_hi; e->store_status = STORE_OK; assert(e->mem_status == NOT_IN_MEMORY); @@ -870,6 +875,11 @@ destroy_StoreEntry(e); } } + +#if USE_HINT_CACHE + hintCacheInvalLocalCopy(e); +#endif + storeLog(STORE_LOG_RELEASE, e); if (e->swap_filen > -1) { storeUnlink(e); Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.47 retrieving revision 1.47.2.1 diff -u -r1.47 -r1.47.2.1 --- squid/src/structs.h 24 Oct 2001 09:42:14 -0000 1.47 +++ squid/src/structs.h 24 Nov 2001 05:53:17 -0000 1.47.2.1 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.47 2001/10/24 09:42:14 squidadm Exp $ + * $Id: structs.h,v 1.47.2.1 2001/11/24 05:53:17 jkay Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -337,6 +337,12 @@ #endif +#if USE_HINT_CACHE +struct _URLKey { + GenericKey key; +}; +#endif + #if DELAY_POOLS struct _delaySpec { int restore_bps; @@ -674,6 +680,17 @@ int unclean_shutdown; } SSL; #endif +#if USE_HINT_CACHE + struct { + char *cachefile; + int size; + int assoc; + int intvl; + int joinintvl; + int usemmap; + int holddown; + } Hints; +#endif wordlist *ext_methods; struct { int high_rptm; @@ -971,6 +988,7 @@ int fd; http_state_flags flags; FwdState *fwd; + int body_remain; }; struct _icpUdpData { @@ -1052,6 +1070,7 @@ } out; HttpHdrRangeIter range_iter; /* data for iterating thru range specs */ size_t req_sz; /* raw request size on input, not current request size */ + char *hdr_str; /* Copy of headers */ StoreEntry *entry; StoreEntry *old_entry; log_type log_type; @@ -1520,6 +1539,10 @@ ping_status_t ping_status:3; store_status_t store_status:3; swap_status_t swap_status:3; + Updatee *updatees; +#if USE_HINT_CACHE + URLKey key; /* 64-bit MD5 hash of URL */ +#endif }; struct _SwapDir { @@ -1644,6 +1667,7 @@ struct in_addr client_addr; struct in_addr my_addr; unsigned short my_port; + unsigned short dport; HttpHeader header; ConnStateData *body_connection; /* used by clientReadBody() */ int content_length; @@ -1842,6 +1866,9 @@ int outs; int ins; } swap; + struct { + int dists; + } push; }; /* per header statistics */ @@ -2155,10 +2182,137 @@ } flags; }; + + +/* + * Putting state. + * By convention, this occupies the beginning of a 4k buffer. + */ +struct _pusher { + int fd; + store_client *sc; + struct { + unsigned int active:1; + unsigned int connected:1; + unsigned int connecting:1; + unsigned int writing:1; + unsigned int dead:1; + unsigned int disting:1; +#ifdef USE_ICPDATA + unsigned int icpdata:1; +#endif + } flags; + int off; + int objlen; + StoreEntry *entry; + PF *handler; + void *arg; +#ifdef USE_ICPDATA + icpQueue *q; +#endif + unsigned reqnum; /* ICP reqnum */ + char hname[20]; +}; + struct cache_dir_option { const char *name; void (*parse) (SwapDir * sd, const char *option, const char *value, int reconfiguring); void (*dump) (StoreEntry * e, const char *option, SwapDir * sd); }; + +/* Tracking state for update ("push") requester */ +struct _updatee { + struct _updatee *next; + StoreEntry *entry; /* Backpointer to relevant entry */ + struct sockaddr_in saddr; + time_t lastmod; + Pusher *p; +}; + + +#if USE_HINT_CACHE + +/* Hint Cache Interface */ +/* + * Primitive data types. All have a Net_ format which has an + * agreed-upon endian-ness. + */ + + +struct _Net_URLKey { + GenericKey mungedKey; +}; + +struct _NodeKey { + List_Links links; /* MUST BE FIRST FIELD OF STRUCT */ + GenericKey key; + struct sockaddr_in addr; +}; + +struct _HintCacheEntry { + URLKey key; + struct in_addr ipaddr; + unsigned short port; + short pad; /* Compiler padding space */ + unsigned int mtime; /* Last-modified time */ +}; + +/* This is what goes onto the net */ +struct _Net_HintCacheEntry { + Net_URLKey mungedKey; + struct in_addr mungedIpaddr; + unsigned short mungedPort; + short mungedPad; + unsigned int mungedMtime; +}; + +struct _HintCacheUpdate { + unsigned char action; + char hopcount; + char UNUSED; /* Remove this field sometime XXX */ + char pad1; + int pad2; + HintCacheEntry entry; +}; + +struct _Net_HintCacheUpdate { + unsigned char mungedAction; + char mungedHopcount; + char mungedUNUSED; + char mungedPad1; + int mungedPad2; + Net_HintCacheEntry mungedEntry; +}; + +/* Hint Cache Disk */ +struct _HintCacheDiskEntry { + HintCacheEntry entry; + unsigned int rtime; /* Time of entry receipt */ +}; + +struct _HintCacheDisk { + unsigned int nbuckets; + int entriesPerBucket; + HintCacheDiskEntry *mmappedArray; + int fd; +}; + +typedef struct HintCacheNetS{ + StoreEntry *sendBuffer; + int sendLength; + enum HintCacheNet_State state; +#ifdef DOTEST + int testMode; + int testCount; +#endif +} HintCacheNet; + +typedef struct HintCacheNetHeaderS { + unsigned short httpport; /* Port of sending server */ + unsigned short updlen; /* Length of individual update */ +} HintCacheNetHeader; + +#endif /* USE_HINT_CACHE */ + #endif /* SQUID_STRUCTS_H */ Index: squid/src/typedefs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/typedefs.h,v retrieving revision 1.25 retrieving revision 1.25.2.1 diff -u -r1.25 -r1.25.2.1 --- squid/src/typedefs.h 10 Oct 2001 18:07:43 -0000 1.25 +++ squid/src/typedefs.h 24 Nov 2001 05:53:17 -0000 1.25.2.1 @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.25 2001/10/10 18:07:43 squidadm Exp $ + * $Id: typedefs.h,v 1.25.2.1 2001/11/24 05:53:17 jkay Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -360,4 +360,30 @@ typedef int STDIRSELECT(const StoreEntry *); +/* PUT internal data structure */ +typedef struct _pusher Pusher; + +/* Automatic update ("push") requester */ +typedef struct _updatee Updatee; + +#if USE_HINT_CACHE +/* Hint Cache Interface */ +typedef unsigned Net_unsigned; +typedef long long unsigned Net_longlong; +typedef unsigned long long GenericKey; +typedef struct _URLKey URLKey; +typedef struct _Net_URLKey Net_URLKey; +typedef struct _NodeKey NodeKey; +typedef struct _HintCacheEntry HintCacheEntry; +typedef struct _Net_HintCacheEntry Net_HintCacheEntry; +typedef struct _HintCacheUpdate HintCacheUpdate; +typedef struct _Net_HintCacheUpdate Net_HintCacheUpdate; + +/* Hint Cache Disk */ +typedef struct _HintCacheDiskEntry HintCacheDiskEntry; +typedef struct _HintCacheDisk HintCacheDisk; + +typedef List_Links *HintCacheNodeListIter; +#endif /* USE_HINT_CACHE */ + #endif /* SQUID_TYPEDEFS_H */