--------------------- PatchSet 5274 Date: 2002/10/07 09:42:48 Author: rbcollins Branch: rbcollins_cxxtest Tag: (none) Log: async storeget for icp Members: src/icp_v3.cc:1.1.2.2->1.1.2.3 Index: squid/src/icp_v3.cc =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icp_v3.cc,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- squid/src/icp_v3.cc 7 Oct 2002 09:22:17 -0000 1.1.2.2 +++ squid/src/icp_v3.cc 7 Oct 2002 09:42:48 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* - * $Id: icp_v3.cc,v 1.1.2.2 2002/10/07 09:22:17 rbcollins Exp $ + * $Id: icp_v3.cc,v 1.1.2.3 2002/10/07 09:42:48 rbcollins Exp $ * * DEBUG: section 12 Internet Cache Protocol * AUTHOR: Duane Wessels @@ -35,9 +35,18 @@ #include "squid.h" #include "Store.h" +#include "StoreClient.h" /* todo: mempool this */ -class ICP3State { +class ICP3State : public StoreClient { +public: + ~ICP3State(); + void created (StoreEntry *newEntry); + icp_common_t header; + request_t *request; + int fd; + struct sockaddr_in from; + char *url; }; static void @@ -83,27 +92,44 @@ return; } /* The peer is allowed to use this cache */ - StoreEntry *entry = storeGetPublic(url, METHOD_GET); + ICP3State *state = new ICP3State; + state->header = header; + state->request = icp_request; + state->fd = fd; + state->from = from; + state->url = xstrdup (url); + _StoreEntry::getPublic (state, url, METHOD_GET); +} + +ICP3State::~ICP3State () +{ + safe_free (url); + if (request) + requestDestroy(request); +} + +void +ICP3State::created (StoreEntry *newEntry) +{ + StoreEntry *entry = newEntry->isNull () ? NULL : newEntry; debug(12, 5) ("icpHandleIcpV3: OPCODE %s\n", icp_opcode_str[header.opcode]); - if (icpCheckUdpHit(entry, icp_request)) { - reply = (icp_common_t *) icpCreateMessage(ICP_HIT, 0, url, header.reqnum, 0); + if (icpCheckUdpHit(entry, request)) { + icp_common_t *reply = (icp_common_t *) icpCreateMessage(ICP_HIT, 0, url, header.reqnum, 0); icpUdpSend(fd, &from, reply, LOG_UDP_HIT, 0); - requestDestroy(icp_request); - return; - } + } else /* if store is rebuilding, return a UDP_HIT, but not a MISS */ if (opt_reload_hit_only && store_dirs_rebuilding) { - reply = (icp_common_t *) icpCreateMessage(ICP_MISS_NOFETCH, 0, url, header.reqnum, 0); + icp_common_t *reply = (icp_common_t *) icpCreateMessage(ICP_MISS_NOFETCH, 0, url, header.reqnum, 0); icpUdpSend(fd, &from, reply, LOG_UDP_MISS_NOFETCH, 0); } else if (hit_only_mode_until > squid_curtime) { - reply = (icp_common_t *) icpCreateMessage(ICP_MISS_NOFETCH, 0, url, header.reqnum, 0); + icp_common_t *reply = (icp_common_t *) icpCreateMessage(ICP_MISS_NOFETCH, 0, url, header.reqnum, 0); icpUdpSend(fd, &from, reply, LOG_UDP_MISS_NOFETCH, 0); } else { - reply = (icp_common_t *) icpCreateMessage(ICP_MISS, 0, url, header.reqnum, 0); + icp_common_t *reply = (icp_common_t *) icpCreateMessage(ICP_MISS, 0, url, header.reqnum, 0); icpUdpSend(fd, &from, reply, LOG_UDP_MISS, 0); } - requestDestroy(icp_request); + delete this; } /* Currently Harvest cached-2.x uses ICP_VERSION_3 */