--------------------- PatchSet 5281 Date: 2002/10/07 15:44:20 Author: rbcollins Branch: rbcollins_cxxtest Tag: (none) Log: simplify conditional Members: src/icp_v2.cc:1.1.2.5->1.1.2.6 src/icp_v3.cc:1.1.2.6->1.1.2.7 Index: squid/src/icp_v2.cc =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icp_v2.cc,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -r1.1.2.5 -r1.1.2.6 --- squid/src/icp_v2.cc 7 Oct 2002 15:34:48 -0000 1.1.2.5 +++ squid/src/icp_v2.cc 7 Oct 2002 15:44:20 -0000 1.1.2.6 @@ -1,6 +1,6 @@ /* - * $Id: icp_v2.cc,v 1.1.2.5 2002/10/07 15:34:48 rbcollins Exp $ + * $Id: icp_v2.cc,v 1.1.2.6 2002/10/07 15:44:20 rbcollins Exp $ * * DEBUG: section 12 Internet Cache Protocol * AUTHOR: Duane Wessels @@ -283,21 +283,26 @@ /* The peer is allowed to use this cache */ StoreEntry *entry = storeGetPublic(url, METHOD_GET); debug(12, 5) ("icpHandleIcpV2: OPCODE %s\n", icp_opcode_str[header.opcode]); + icp_opcode codeToSend; if (icpCheckUdpHit(entry, icp_request)) { - icpReallyCreateAndSend(ICP_HIT, flags, url, header.reqnum, src_rtt, fd, &from); - requestDestroy(icp_request); - return; - } - if (Config.onoff.test_reachability && rtt == 0) { - if ((rtt = netdbHostRtt(icp_request->host)) == 0) - netdbPingSite(icp_request->host); - } - if (!icpCreateAndSend(fd, &from, flags, url, header.reqnum, src_rtt)) { - if (Config.onoff.test_reachability && rtt == 0) - icpReallyCreateAndSend(ICP_MISS_NOFETCH, flags, url, header.reqnum, src_rtt, fd, &from); - else - icpReallyCreateAndSend(ICP_MISS, flags, url, header.reqnum, src_rtt, fd, &from); + codeToSend = ICP_HIT; + } else { + if (Config.onoff.test_reachability && rtt == 0) { + if ((rtt = netdbHostRtt(icp_request->host)) == 0) + netdbPingSite(icp_request->host); + } + if (!icpCreateAndSend(fd, &from, flags, url, header.reqnum, src_rtt)) { + icp_opcode codeToSend; + if (Config.onoff.test_reachability && rtt == 0) + codeToSend = ICP_MISS_NOFETCH; + else + codeToSend = ICP_MISS; + } else { + requestDestroy(icp_request); + return; + } } + icpReallyCreateAndSend(codeToSend, flags, url, header.reqnum, src_rtt, fd, &from); requestDestroy(icp_request); } Index: squid/src/icp_v3.cc =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icp_v3.cc,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -r1.1.2.6 -r1.1.2.7 --- squid/src/icp_v3.cc 7 Oct 2002 15:33:28 -0000 1.1.2.6 +++ squid/src/icp_v3.cc 7 Oct 2002 15:44:20 -0000 1.1.2.7 @@ -1,6 +1,6 @@ /* - * $Id: icp_v3.cc,v 1.1.2.6 2002/10/07 15:33:28 rbcollins Exp $ + * $Id: icp_v3.cc,v 1.1.2.7 2002/10/07 15:44:20 rbcollins Exp $ * * DEBUG: section 12 Internet Cache Protocol * AUTHOR: Duane Wessels @@ -109,11 +109,16 @@ StoreEntry *entry = newEntry->isNull () ? NULL : newEntry; debug(12, 5) ("icpHandleIcpV3: OPCODE %s\n", icp_opcode_str[header.opcode]); + icp_opcode codeToSend; if (icpCheckUdpHit(entry, request)) { - icpReallyCreateAndSend (ICP_HIT, 0, url, header.reqnum, 0, fd, &from); + codeToSend = ICP_HIT; } else if (!icpCreateAndSend(fd, &from, 0, url, header.reqnum,0)) { - icpReallyCreateAndSend (ICP_MISS, 0, url, header.reqnum, 0, fd, &from); + codeToSend = ICP_MISS; + } else { + delete this; + return; } + icpReallyCreateAndSend (codeToSend, 0, url, header.reqnum, 0, fd, &from); delete this; }