2 * DEBUG: section 12 Internet Cache Protocol (ICP)
3 * AUTHOR: Duane Wessels
5 * SQUID Web Proxy Cache http://www.squid-cache.org/
6 * ----------------------------------------------------------
8 * Squid is the result of efforts by numerous individuals from
9 * the Internet community; see the CONTRIBUTORS file for full
10 * details. Many organizations have provided support for Squid's
11 * development; see the SPONSORS file for full details. Squid is
12 * Copyrighted (C) 2001 by the Regents of the University of
13 * California; see the COPYRIGHT file for full details. Squid
14 * incorporates software developed and/or copyrighted by other
15 * sources; see the CREDITS file for full details.
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
34 \defgroup ServerProtocolICPInternal2 ICPv2 Internals
35 \ingroup ServerProtocolICPAPI
41 #include "comm/Loops.h"
43 #include "comm/Connection.h"
44 #include "HttpRequest.h"
45 #include "acl/FilledChecklist.h"
47 #include "AccessLogEntry.h"
49 #include "SquidTime.h"
51 #include "icmp/net_db.h"
52 #include "ip/Address.h"
54 #include "ipc/StartListening.h"
58 /// dials icpIncomingConnectionOpened call
59 class IcpListeningStartedDialer
: public CallDialer
,
60 public Ipc::StartListeningCb
63 typedef void (*Handler
)(int errNo
);
64 IcpListeningStartedDialer(Handler aHandler
):
67 virtual void print(std::ostream
&os
) const { startPrint(os
) << ')'; }
68 virtual bool canDial(AsyncCall
&) const { return true; }
69 virtual void dial(AsyncCall
&) { (handler
)(errNo
); }
75 static void icpIncomingConnectionOpened(int errNo
);
77 /// \ingroup ServerProtocolICPInternal2
78 static void icpLogIcp(const Ip::Address
&, log_type
, int, const char *, int);
80 /// \ingroup ServerProtocolICPInternal2
81 static void icpHandleIcpV2(int, Ip::Address
&, char *, int);
83 /// \ingroup ServerProtocolICPInternal2
84 static void icpCount(void *, int, size_t, int);
87 \ingroup ServerProtocolICPInternal2
88 * IcpQueueHead is global so comm_incoming() knows whether or not
89 * to call icpUdpSendQueue.
91 static icpUdpData
*IcpQueueHead
= NULL
;
92 /// \ingroup ServerProtocolICPInternal2
93 static icpUdpData
*IcpQueueTail
= NULL
;
95 /// \ingroup ServerProtocolICPInternal2
96 Comm::ConnectionPointer icpIncomingConn
= NULL
;
97 /// \ingroup ServerProtocolICPInternal2
98 Comm::ConnectionPointer icpOutgoingConn
= NULL
;
101 _icp_common_t::_icp_common_t() : opcode(ICP_INVALID
), version(0), length(0), reqnum(0), flags(0), pad(0), shostid(0)
104 _icp_common_t::_icp_common_t(char *buf
, unsigned int len
)
106 if (len
< sizeof(_icp_common_t
)) {
107 /* mark as invalid */
112 memcpy(this, buf
, sizeof(icp_common_t
));
114 * Convert network order sensitive fields
116 length
= ntohs(length
);
117 reqnum
= ntohl(reqnum
);
118 flags
= ntohl(flags
);
123 _icp_common_t::getOpCode() const
125 if (opcode
> (char)ICP_END
)
128 return (icp_opcode
)opcode
;
133 ICPState::ICPState(icp_common_t
&aHeader
, HttpRequest
*aRequest
):
135 request(HTTPMSGLOCK(aRequest
)),
140 ICPState::~ICPState()
143 HTTPMSGUNLOCK(request
);
151 /// \ingroup ServerProtocolICPInternal2
152 class ICP2State
: public ICPState
, public StoreClient
156 ICP2State(icp_common_t
& aHeader
, HttpRequest
*aRequest
):
157 ICPState(aHeader
, aRequest
),rtt(0),src_rtt(0),flags(0) {}
160 void created(StoreEntry
* newEntry
);
167 ICP2State::~ICP2State()
171 ICP2State::created(StoreEntry
*newEntry
)
173 StoreEntry
*entry
= newEntry
->isNull () ? NULL
: newEntry
;
174 debugs(12, 5, "icpHandleIcpV2: OPCODE " << icp_opcode_str
[header
.opcode
]);
175 icp_opcode codeToSend
;
177 if (icpCheckUdpHit(entry
, request
)) {
178 codeToSend
= ICP_HIT
;
181 if (Config
.onoff
.test_reachability
&& rtt
== 0) {
182 if ((rtt
= netdbHostRtt(request
->GetHost())) == 0)
183 netdbPingSite(request
->GetHost());
185 #endif /* USE_ICMP */
187 if (icpGetCommonOpcode() != ICP_ERR
)
188 codeToSend
= icpGetCommonOpcode();
189 else if (Config
.onoff
.test_reachability
&& rtt
== 0)
190 codeToSend
= ICP_MISS_NOFETCH
;
192 codeToSend
= ICP_MISS
;
195 icpCreateAndSend(codeToSend
, flags
, url
, header
.reqnum
, src_rtt
, fd
, from
);
201 /// \ingroup ServerProtocolICPInternal2
203 icpLogIcp(const Ip::Address
&caddr
, log_type logcode
, int len
, const char *url
, int delay
)
207 if (LOG_TAG_NONE
== logcode
)
210 if (LOG_ICP_QUERY
== logcode
)
213 clientdbUpdate(caddr
, logcode
, AnyP::PROTO_ICP
, len
);
215 if (!Config
.onoff
.log_udp
)
218 al
.icp
.opcode
= ICP_QUERY
;
222 al
.cache
.caddr
= caddr
;
224 al
.cache
.replySize
= len
;
226 al
.cache
.code
= logcode
;
228 al
.cache
.msec
= delay
;
230 accessLogLog(&al
, NULL
);
233 /// \ingroup ServerProtocolICPInternal2
235 icpUdpSendQueue(int fd
, void *unused
)
239 while ((q
= IcpQueueHead
) != NULL
) {
240 int delay
= tvSubUsec(q
->queue_time
, current_time
);
241 /* increment delay to prevent looping */
242 const int x
= icpUdpSend(fd
, q
->address
, (icp_common_t
*) q
->msg
, q
->logcode
, ++delay
);
243 IcpQueueHead
= q
->next
;
252 _icp_common_t::createMessage(
260 icp_common_t
*headerp
= NULL
;
261 char *urloffset
= NULL
;
263 buf_len
= sizeof(icp_common_t
) + strlen(url
) + 1;
265 if (opcode
== ICP_QUERY
)
266 buf_len
+= sizeof(uint32_t);
268 buf
= (char *) xcalloc(buf_len
, 1);
270 headerp
= (icp_common_t
*) (void *) buf
;
272 headerp
->opcode
= (char) opcode
;
274 headerp
->version
= ICP_VERSION_CURRENT
;
276 headerp
->length
= (uint16_t) htons(buf_len
);
278 headerp
->reqnum
= htonl(reqnum
);
280 headerp
->flags
= htonl(flags
);
282 headerp
->pad
= htonl(pad
);
284 headerp
->shostid
= 0;
286 urloffset
= buf
+ sizeof(icp_common_t
);
288 if (opcode
== ICP_QUERY
)
289 urloffset
+= sizeof(uint32_t);
291 memcpy(urloffset
, url
, strlen(url
));
293 return (icp_common_t
*)buf
;
298 const Ip::Address
&to
,
306 len
= (int) ntohs(msg
->length
);
307 debugs(12, 5, "icpUdpSend: FD " << fd
<< " sending " <<
308 icp_opcode_str
[msg
->opcode
] << ", " << len
<< " bytes to " << to
);
310 x
= comm_udp_sendto(fd
, to
, msg
, len
);
313 /* successfully written */
314 icpLogIcp(to
, logcode
, len
, (char *) (msg
+ 1), delay
);
315 icpCount(msg
, SENT
, (size_t) len
, delay
);
317 } else if (0 == delay
) {
318 /* send failed, but queue it */
319 queue
= (icpUdpData
*) xcalloc(1, sizeof(icpUdpData
));
322 queue
->len
= (int) ntohs(msg
->length
);
323 queue
->queue_time
= current_time
;
324 queue
->logcode
= logcode
;
326 if (IcpQueueHead
== NULL
) {
327 IcpQueueHead
= queue
;
328 IcpQueueTail
= queue
;
329 } else if (IcpQueueTail
== IcpQueueHead
) {
330 IcpQueueTail
= queue
;
331 IcpQueueHead
->next
= queue
;
333 IcpQueueTail
->next
= queue
;
334 IcpQueueTail
= queue
;
337 Comm::SetSelect(fd
, COMM_SELECT_WRITE
, icpUdpSendQueue
, NULL
, 0);
338 statCounter
.icp
.replies_queued
++;
341 statCounter
.icp
.replies_dropped
++;
348 icpCheckUdpHit(StoreEntry
* e
, HttpRequest
* request
)
353 if (!e
->validToSend())
356 if (Config
.onoff
.icp_hit_stale
)
359 if (refreshCheckICP(e
, request
))
366 * This routine selects an ICP opcode for ICP misses.
368 \retval ICP_ERR no opcode selected here
369 \retval ICP_MISS_NOFETCH store is rebuilding, no fetch is possible yet
374 /* if store is rebuilding, return a UDP_MISS_NOFETCH */
376 if ((StoreController::store_dirs_rebuilding
&& opt_reload_hit_only
) ||
377 hit_only_mode_until
> squid_curtime
) {
378 return ICP_MISS_NOFETCH
;
385 icpLogFromICPCode(icp_opcode opcode
)
387 if (opcode
== ICP_ERR
)
388 return LOG_UDP_INVALID
;
390 if (opcode
== ICP_DENIED
)
391 return LOG_UDP_DENIED
;
393 if (opcode
== ICP_HIT
)
396 if (opcode
== ICP_MISS
)
399 if (opcode
== ICP_MISS_NOFETCH
)
400 return LOG_UDP_MISS_NOFETCH
;
402 fatal("expected ICP opcode\n");
404 return LOG_UDP_INVALID
;
408 icpCreateAndSend(icp_opcode opcode
, int flags
, char const *url
, int reqnum
, int pad
, int fd
, const Ip::Address
&from
)
410 icp_common_t
*reply
= _icp_common_t::createMessage(opcode
, flags
, url
, reqnum
, pad
);
411 icpUdpSend(fd
, from
, reply
, icpLogFromICPCode(opcode
), 0);
415 icpDenyAccess(Ip::Address
&from
, char *url
, int reqnum
, int fd
)
417 debugs(12, 2, "icpDenyAccess: Access Denied for " << from
<< " by " << AclMatchedName
<< ".");
419 if (clientdbCutoffDenied(from
)) {
421 * count this DENIED query in the clientdb, even though
422 * we're not sending an ICP reply...
424 clientdbUpdate(from
, LOG_UDP_DENIED
, AnyP::PROTO_ICP
, 0);
426 icpCreateAndSend(ICP_DENIED
, 0, url
, reqnum
, 0, fd
, from
);
431 icpAccessAllowed(Ip::Address
&from
, HttpRequest
* icp_request
)
433 /* absent an explicit allow, we deny all */
434 if (!Config
.accessList
.icp
)
437 ACLFilledChecklist
checklist(Config
.accessList
.icp
, icp_request
, NULL
);
438 checklist
.src_addr
= from
;
439 checklist
.my_addr
.SetNoAddr();
440 return (checklist
.fastCheck() == ACCESS_ALLOWED
);
444 icpGetUrlToSend(char *url
)
446 if (strpbrk(url
, w_space
))
447 return rfc1738_escape(url
);
453 icpGetRequest(char *url
, int reqnum
, int fd
, Ip::Address
&from
)
455 if (strpbrk(url
, w_space
)) {
456 url
= rfc1738_escape(url
);
457 icpCreateAndSend(ICP_ERR
, 0, rfc1738_escape(url
), reqnum
, 0, fd
, from
);
463 if ((result
= HttpRequest::CreateFromUrl(url
)) == NULL
)
464 icpCreateAndSend(ICP_ERR
, 0, url
, reqnum
, 0, fd
, from
);
471 doV2Query(int fd
, Ip::Address
&from
, char *buf
, icp_common_t header
)
476 /* We have a valid packet */
477 char *url
= buf
+ sizeof(icp_common_t
) + sizeof(uint32_t);
478 HttpRequest
*icp_request
= icpGetRequest(url
, header
.reqnum
, fd
, from
);
483 HTTPMSGLOCK(icp_request
);
485 if (!icpAccessAllowed(from
, icp_request
)) {
486 icpDenyAccess(from
, url
, header
.reqnum
, fd
);
487 HTTPMSGUNLOCK(icp_request
);
491 if (header
.flags
& ICP_FLAG_SRC_RTT
) {
492 rtt
= netdbHostRtt(icp_request
->GetHost());
493 int hops
= netdbHostHops(icp_request
->GetHost());
494 src_rtt
= ((hops
& 0xFFFF) << 16) | (rtt
& 0xFFFF);
497 flags
|= ICP_FLAG_SRC_RTT
;
499 #endif /* USE_ICMP */
501 /* The peer is allowed to use this cache */
502 ICP2State
*state
= new ICP2State (header
, icp_request
);
508 state
->url
= xstrdup (url
);
510 state
->flags
= flags
;
514 state
->src_rtt
= src_rtt
;
516 StoreEntry::getPublic (state
, url
, METHOD_GET
);
518 HTTPMSGUNLOCK(icp_request
);
522 _icp_common_t::handleReply(char *buf
, Ip::Address
&from
)
524 if (neighbors_do_private_keys
&& reqnum
== 0) {
525 debugs(12, 0, "icpHandleIcpV2: Neighbor " << from
<< " returned reqnum = 0");
526 debugs(12, 0, "icpHandleIcpV2: Disabling use of private keys");
527 neighbors_do_private_keys
= 0;
530 char *url
= buf
+ sizeof(icp_common_t
);
531 debugs(12, 3, "icpHandleIcpV2: " << icp_opcode_str
[opcode
] << " from " << from
<< " for '" << url
<< "'");
533 const cache_key
*key
= icpGetCacheKey(url
, (int) reqnum
);
534 /* call neighborsUdpAck even if ping_status != PING_WAITING */
535 neighborsUdpAck(key
, this, from
);
539 icpHandleIcpV2(int fd
, Ip::Address
&from
, char *buf
, int len
)
542 debugs(12, 3, "icpHandleIcpV2: ICP message is too small");
546 icp_common_t
header(buf
, len
);
548 * Length field should match the number of bytes read
551 if (len
!= header
.length
) {
552 debugs(12, 3, "icpHandleIcpV2: ICP message is too small");
556 switch (header
.opcode
) {
559 /* We have a valid packet */
560 doV2Query(fd
, from
, buf
, header
);
571 case ICP_MISS_NOFETCH
:
572 header
.handleReply(buf
, from
);
581 debugs(12, 0, "icpHandleIcpV2: UNKNOWN OPCODE: " << header
.opcode
<< " from " << from
);
589 icpPktDump(icp_common_t
* pkt
)
593 debugs(12, 9, "opcode: " << std::setw(3) << pkt
->opcode
<< " " << icp_opcode_str
[pkt
->opcode
]);
594 debugs(12, 9, "version: "<< std::left
<< std::setw(8) << pkt
->version
);
595 debugs(12, 9, "length: "<< std::left
<< std::setw(8) << ntohs(pkt
->length
));
596 debugs(12, 9, "reqnum: "<< std::left
<< std::setw(8) << ntohl(pkt
->reqnum
));
597 debugs(12, 9, "flags: "<< std::left
<< std::hex
<< std::setw(8) << ntohl(pkt
->flags
));
598 a
= (struct in_addr
)pkt
->shostid
;
599 debugs(12, 9, "shostid: " << a
);
600 debugs(12, 9, "payload: " << (char *) pkt
+ sizeof(icp_common_t
));
606 icpHandleUdp(int sock
, void *data
)
608 int *N
= &incoming_sockets_accepted
;
611 LOCAL_ARRAY(char, buf
, SQUID_UDP_SO_RCVBUF
);
614 int max
= INCOMING_ICP_MAX
;
615 Comm::SetSelect(sock
, COMM_SELECT_READ
, icpHandleUdp
, NULL
, 0);
618 len
= comm_udp_recvfrom(sock
,
620 SQUID_UDP_SO_RCVBUF
- 1,
628 if (ignoreErrno(errno
))
632 /* Some Linux systems seem to set the FD for reading and then
633 * return ECONNREFUSED when sendto() fails and generates an ICMP
634 * port unreachable message. */
635 /* or maybe an EHOSTUNREACH "No route to host" message */
636 if (errno
!= ECONNREFUSED
&& errno
!= EHOSTUNREACH
)
639 debugs(50, 1, "icpHandleUdp: FD " << sock
<< " recvfrom: " << xstrerror());
645 icpCount(buf
, RECV
, (size_t) len
, 0);
647 debugs(12, 4, "icpHandleUdp: FD " << sock
<< ": received " <<
648 (unsigned long int)len
<< " bytes from " << from
);
650 #ifdef ICP_PACKET_DUMP
655 if ((size_t) len
< sizeof(icp_common_t
)) {
656 debugs(12, 4, "icpHandleUdp: Ignoring too-small UDP packet");
660 icp_version
= (int) buf
[1]; /* cheat! */
662 if (icpOutgoingConn
->local
== from
)
663 // ignore ICP packets which loop back (multicast usually)
664 debugs(12, 4, "icpHandleUdp: Ignoring UDP packet sent by myself");
665 else if (icp_version
== ICP_VERSION_2
)
666 icpHandleIcpV2(sock
, from
, buf
, len
);
667 else if (icp_version
== ICP_VERSION_3
)
668 icpHandleIcpV3(sock
, from
, buf
, len
);
670 debugs(12, 1, "WARNING: Unused ICP version " << icp_version
<<
671 " received from " << from
);
676 icpConnectionsOpen(void)
680 if ((port
= Config
.Port
.icp
) <= 0)
683 icpIncomingConn
= new Comm::Connection
;
684 icpIncomingConn
->local
= Config
.Addrs
.udp_incoming
;
685 icpIncomingConn
->local
.SetPort(port
);
687 if (!Ip::EnableIpv6
&& !icpIncomingConn
->local
.SetIPv4()) {
688 debugs(12, DBG_CRITICAL
, "ERROR: IPv6 is disabled. " << icpIncomingConn
->local
<< " is not an IPv4 address.");
689 fatal("ICP port cannot be opened.");
691 /* split-stack for now requires default IPv4-only ICP */
692 if (Ip::EnableIpv6
&IPV6_SPECIAL_SPLITSTACK
&& icpIncomingConn
->local
.IsAnyAddr()) {
693 icpIncomingConn
->local
.SetIPv4();
696 AsyncCall::Pointer call
= asyncCall(12, 2,
697 "icpIncomingConnectionOpened",
698 IcpListeningStartedDialer(&icpIncomingConnectionOpened
));
700 Ipc::StartListening(SOCK_DGRAM
,
703 Ipc::fdnInIcpSocket
, call
);
705 if ( !Config
.Addrs
.udp_outgoing
.IsNoAddr() ) {
706 icpOutgoingConn
= new Comm::Connection
;
707 icpOutgoingConn
->local
= Config
.Addrs
.udp_outgoing
;
708 icpOutgoingConn
->local
.SetPort(port
);
710 if (!Ip::EnableIpv6
&& !icpOutgoingConn
->local
.SetIPv4()) {
711 debugs(49, DBG_CRITICAL
, "ERROR: IPv6 is disabled. " << icpOutgoingConn
->local
<< " is not an IPv4 address.");
712 fatal("ICP port cannot be opened.");
714 /* split-stack for now requires default IPv4-only ICP */
715 if (Ip::EnableIpv6
&IPV6_SPECIAL_SPLITSTACK
&& icpOutgoingConn
->local
.IsAnyAddr()) {
716 icpOutgoingConn
->local
.SetIPv4();
720 comm_open_listener(SOCK_DGRAM
, IPPROTO_UDP
, icpOutgoingConn
, "Outgoing ICP Port");
723 if (!Comm::IsConnOpen(icpOutgoingConn
))
724 fatal("Cannot open Outgoing ICP Port");
726 debugs(12, DBG_CRITICAL
, "Sending ICP messages from " << icpOutgoingConn
->local
);
728 Comm::SetSelect(icpOutgoingConn
->fd
, COMM_SELECT_READ
, icpHandleUdp
, NULL
, 0);
729 fd_note(icpOutgoingConn
->fd
, "Outgoing ICP socket");
734 icpIncomingConnectionOpened(int errNo
)
736 if (!Comm::IsConnOpen(icpIncomingConn
))
737 fatal("Cannot open ICP Port");
739 Comm::SetSelect(icpIncomingConn
->fd
, COMM_SELECT_READ
, icpHandleUdp
, NULL
, 0);
741 for (const wordlist
*s
= Config
.mcast_group_list
; s
; s
= s
->next
)
742 ipcache_nbgethostbyname(s
->key
, mcastJoinGroups
, NULL
); // XXX: pass the icpIncomingConn for mcastJoinGroups usage.
744 debugs(12, DBG_IMPORTANT
, "Accepting ICP messages on " << icpIncomingConn
->local
);
746 fd_note(icpIncomingConn
->fd
, "Incoming ICP port");
748 if (Config
.Addrs
.udp_outgoing
.IsNoAddr()) {
749 icpOutgoingConn
= icpIncomingConn
;
750 debugs(12, DBG_IMPORTANT
, "Sending ICP messages from " << icpOutgoingConn
->local
);
755 * icpConnectionShutdown only closes the 'in' socket if it is
756 * different than the 'out' socket.
759 icpConnectionShutdown(void)
761 if (!Comm::IsConnOpen(icpIncomingConn
))
764 debugs(12, DBG_IMPORTANT
, "Stop receiving ICP on " << icpIncomingConn
->local
);
766 /** Release the 'in' socket for lazy closure.
767 * in and out sockets may be sharing one same FD.
768 * This prevents this function from executing repeatedly.
770 icpIncomingConn
= NULL
;
773 * Normally we only write to the outgoing ICP socket, but
774 * we also have a read handler there to catch messages sent
775 * to that specific interface. During shutdown, we must
776 * disable reading on the outgoing socket.
778 assert(Comm::IsConnOpen(icpOutgoingConn
));
780 Comm::SetSelect(icpOutgoingConn
->fd
, COMM_SELECT_READ
, NULL
, NULL
, 0);
784 icpConnectionClose(void)
786 icpConnectionShutdown();
788 if (icpOutgoingConn
!= NULL
) {
789 debugs(12, DBG_IMPORTANT
, "Stop sending ICP from " << icpOutgoingConn
->local
);
790 icpOutgoingConn
= NULL
;
795 icpCount(void *buf
, int which
, size_t len
, int delay
)
797 icp_common_t
*icp
= (icp_common_t
*) buf
;
799 if (len
< sizeof(*icp
))
803 statCounter
.icp
.pkts_sent
++;
804 kb_incr(&statCounter
.icp
.kbytes_sent
, len
);
806 if (ICP_QUERY
== icp
->opcode
) {
807 statCounter
.icp
.queries_sent
++;
808 kb_incr(&statCounter
.icp
.q_kbytes_sent
, len
);
810 statCounter
.icp
.replies_sent
++;
811 kb_incr(&statCounter
.icp
.r_kbytes_sent
, len
);
812 /* this is the sent-reply service time */
813 statHistCount(&statCounter
.icp
.reply_svc_time
, delay
);
816 if (ICP_HIT
== icp
->opcode
)
817 statCounter
.icp
.hits_sent
++;
818 } else if (RECV
== which
) {
819 statCounter
.icp
.pkts_recv
++;
820 kb_incr(&statCounter
.icp
.kbytes_recv
, len
);
822 if (ICP_QUERY
== icp
->opcode
) {
823 statCounter
.icp
.queries_recv
++;
824 kb_incr(&statCounter
.icp
.q_kbytes_recv
, len
);
826 statCounter
.icp
.replies_recv
++;
827 kb_incr(&statCounter
.icp
.r_kbytes_recv
, len
);
828 /* statCounter.icp.query_svc_time set in clientUpdateCounters */
831 if (ICP_HIT
== icp
->opcode
)
832 statCounter
.icp
.hits_recv
++;
836 #define N_QUERIED_KEYS 8192
837 #define N_QUERIED_KEYS_MASK 8191
838 static cache_key queried_keys
[N_QUERIED_KEYS
][SQUID_MD5_DIGEST_LENGTH
];
841 icpSetCacheKey(const cache_key
* key
)
843 static int reqnum
= 0;
848 storeKeyCopy(queried_keys
[reqnum
& N_QUERIED_KEYS_MASK
], key
);
854 icpGetCacheKey(const char *url
, int reqnum
)
856 if (neighbors_do_private_keys
&& reqnum
)
857 return queried_keys
[reqnum
& N_QUERIED_KEYS_MASK
];
859 return storeKeyPublic(url
, METHOD_GET
);