Squid-2.3.DEVEL2: ICP timeout selection This is an attempt to fix the dynamic ICP timeout selection when one is peering with remote parents and have some close-by siblings with a much lower ICP rtt. This is done by preferring to calculate the ICP timeout based on parents only (based on siblings if there is no alive parents) Index: squid/src/neighbors.c diff -u squid/src/neighbors.c:1.1.1.34.2.3 squid/src/neighbors.c:1.1.1.34.2.4 --- squid/src/neighbors.c:1.1.1.34.2.3 Sat Aug 7 19:42:13 1999 +++ squid/src/neighbors.c Sat Aug 7 19:57:48 1999 @@ -374,6 +374,8 @@ icp_common_t *query; int queries_sent = 0; int peers_pinged = 0; + int parent_timeout = 0, parent_exprep = 0; + int sibling_timeout = 0, sibling_exprep = 0; if (Config.peers == NULL) return 0; @@ -383,7 +385,6 @@ mem->start_ping = current_time; mem->ping_reply_callback = callback; mem->ircb_data = callback_data; - *timeout = 0.0; reqnum = icpSetCacheKey(entry->key); for (i = 0, p = first_ping; i++ < Config.npeers; p = p->next) { if (p == NULL) @@ -438,8 +439,13 @@ (*exprep) += p->mcast.n_replies_expected; } else if (neighborUp(p)) { /* its alive, expect a reply from it */ - (*exprep)++; - (*timeout) += p->stats.rtt; + if (neighborType(p, request) == PEER_PARENT) { + parent_exprep++; + parent_timeout += p->stats.rtt; + } else { + sibling_exprep++; + sibling_timeout += p->stats.rtt; + } } else { /* Neighbor is dead; ping it anyway, but don't expect a reply */ /* log it once at the threshold */ @@ -489,14 +495,22 @@ } #endif /* + * How many replies to expect? + */ + *exprep = parent_exprep + sibling_exprep; + + /* * If there is a configured timeout, use it */ if (Config.Timeout.icp_query) *timeout = Config.Timeout.icp_query; else { - if (*exprep > 0) - (*timeout) = 2 * (*timeout) / (*exprep); - else + if (*exprep > 0) { + if (parent_exprep) + *timeout = 2 * parent_timeout / parent_exprep; + else + *timeout = 2 * sibling_timeout / sibling_exprep; + } else *timeout = 2000; /* 2 seconds */ if (Config.Timeout.icp_query_max) if (*timeout > Config.Timeout.icp_query_max)