[squid-users] Re: how to configure squid to always return ICP_HIT- diff / solution

From: Gabriel Wicke <groups@dont-contact.us>
Date: Tue, 13 Apr 2004 21:00:59 +0200

Sorry to respond to myself, hope the quick&dirty hack i came up with
is useful for somebody else. The patched squid is running on the apache
machines at nice 19, taking up <1% cpu. Load distribution is much more
even than with the round-robin setup, especially if something else is
running on one of the apaches (or if the apaches are not identical
machines).

diff -r squid-2.5.STABLE4-20040219/src/icp_v2.c squid-2.5.STABLE4-20040219_always_hit/src/icp_v2.c
253,279c253,257
< /* The peer is allowed to use this cache */
< entry = storeGetPublic(url, METHOD_GET);
< debug(12, 5) ("icpHandleIcpV2: OPCODE %s\n", icp_opcode_str[header.opcode]);
< if (icpCheckUdpHit(entry, icp_request)) {
< reply = icpCreateMessage(ICP_HIT, flags, url, header.reqnum, src_rtt);
< icpUdpSend(fd, &from, reply, LOG_UDP_HIT, 0);
< break;
< }
< if (Config.onoff.test_reachability && rtt == 0) {
< if ((rtt = netdbHostRtt(icp_request->host)) == 0)
< netdbPingSite(icp_request->host);
< }
< /* if store is rebuilding, return a UDP_HIT, but not a MISS */
< if (store_dirs_rebuilding && opt_reload_hit_only) {
< reply = icpCreateMessage(ICP_MISS_NOFETCH, flags, url, header.reqnum, src_rtt);
< icpUdpSend(fd, &from, reply, LOG_UDP_MISS_NOFETCH, 0);
< } else if (hit_only_mode_until > squid_curtime) {
< reply = icpCreateMessage(ICP_MISS_NOFETCH, flags, url, header.reqnum, src_rtt);
< icpUdpSend(fd, &from, reply, LOG_UDP_MISS_NOFETCH, 0);
< } else if (Config.onoff.test_reachability && rtt == 0) {
< reply = icpCreateMessage(ICP_MISS_NOFETCH, flags, url, header.reqnum, src_rtt);
< icpUdpSend(fd, &from, reply, LOG_UDP_MISS_NOFETCH, 0);
< } else {
< reply = icpCreateMessage(ICP_MISS, flags, url, header.reqnum, src_rtt);
< icpUdpSend(fd, &from, reply, LOG_UDP_MISS, 0);
< }
< break;

---
>         /* The peer is allowed to use this cache */
>         debug(12, 5) ("icpHandleIcpV2: OPCODE %s\n", icp_opcode_str[header.opcode]);
>         reply = icpCreateMessage(ICP_HIT, flags, url, header.reqnum, src_rtt);
>         icpUdpSend(fd, &from, reply, LOG_UDP_HIT, 0);
>         break;
diff -r squid-2.5.STABLE4-20040219/src/icp_v3.c squid-2.5.STABLE4-20040219_always_hit/src/icp_v3.c
101,120c101,105
<       entry = storeGetPublic(url, METHOD_GET);
<       debug(12, 5) ("icpHandleIcpV3: OPCODE %s\n",
<           icp_opcode_str[header.opcode]);
<       if (icpCheckUdpHit(entry, icp_request)) {
<           reply = icpCreateMessage(ICP_HIT, 0, url, header.reqnum, 0);
<           icpUdpSend(fd, &from, reply, LOG_UDP_HIT, 0);
<           break;
<       }
<       /* if store is rebuilding, return a UDP_HIT, but not a MISS */
<       if (opt_reload_hit_only && store_dirs_rebuilding) {
<           reply = 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 = icpCreateMessage(ICP_MISS_NOFETCH, 0, url, header.reqnum, 0);
<           icpUdpSend(fd, &from, reply, LOG_UDP_MISS_NOFETCH, 0);
<       } else {
<           reply = icpCreateMessage(ICP_MISS, 0, url, header.reqnum, 0);
<           icpUdpSend(fd, &from, reply, LOG_UDP_MISS, 0);
<       }
<       break;
---
>         debug(12, 5) ("icpHandleIcpV3: OPCODE %s\n",
>                 icp_opcode_str[header.opcode]);
>         reply = icpCreateMessage(ICP_HIT, 0, url, header.reqnum, 0);
>         icpUdpSend(fd, &from, reply, LOG_UDP_HIT, 0);
>         break;
-- 
Gabriel Wicke
Received on Tue Apr 13 2004 - 13:01:09 MDT

This archive was generated by hypermail pre-2.1.9 : Fri Apr 30 2004 - 12:00:02 MDT