]>
Commit | Line | Data |
---|---|---|
495e7591 AM |
1 | Index: squid/src/cf.data.pre |
2 | diff -c squid/src/cf.data.pre:1.245.2.53 squid/src/cf.data.pre:1.245.2.54 | |
3 | *** squid/src/cf.data.pre:1.245.2.53 Fri Nov 28 12:14:31 2003 | |
4 | --- squid/src/cf.data.pre Sat Nov 29 11:52:58 2003 | |
5 | *************** | |
6 | *** 3115,3129 **** | |
7 | NAME: maximum_single_addr_tries | |
8 | TYPE: int | |
9 | LOC: Config.retry.maxtries | |
10 | ! DEFAULT: 3 | |
11 | DOC_START | |
12 | This sets the maximum number of connection attempts for a | |
13 | host that only has one address (for multiple-address hosts, | |
14 | each address is tried once). | |
15 | ||
16 | ! The default value is three tries, the (not recommended) | |
17 | maximum is 255 tries. A warning message will be generated | |
18 | if it is set to a value greater than ten. | |
19 | DOC_END | |
20 | ||
21 | NAME: snmp_port | |
22 | --- 3115,3132 ---- | |
23 | NAME: maximum_single_addr_tries | |
24 | TYPE: int | |
25 | LOC: Config.retry.maxtries | |
26 | ! DEFAULT: 1 | |
27 | DOC_START | |
28 | This sets the maximum number of connection attempts for a | |
29 | host that only has one address (for multiple-address hosts, | |
30 | each address is tried once). | |
31 | ||
32 | ! The default value is one attempt, the (not recommended) | |
33 | maximum is 255 tries. A warning message will be generated | |
34 | if it is set to a value greater than ten. | |
35 | + | |
36 | + Note: This is in addition to the request reforwarding which | |
37 | + takes place if Squid fails to get a satisfying response. | |
38 | DOC_END | |
39 | ||
40 | NAME: snmp_port | |
41 | *************** | |
42 | *** 3585,3590 **** | |
43 | --- 3588,3597 ---- | |
44 | By combining nonhierarchical_direct off and prefer_direct on you | |
45 | can set up Squid to use a parent as a backup path if going direct | |
46 | fails. | |
47 | + | |
48 | + Note: If you want Squid to use parents for all requests then see | |
49 | + the never_direct directive. prefer_direct only modifies how Squid | |
50 | + acts on cachable requests. | |
51 | DOC_END | |
52 | ||
53 | NAME: strip_query_terms | |
54 | Index: squid/src/comm.c | |
55 | diff -c squid/src/comm.c:1.324.2.2 squid/src/comm.c:1.324.2.3 | |
56 | *** squid/src/comm.c:1.324.2.2 Sun Mar 31 23:03:38 2002 | |
57 | --- squid/src/comm.c Sat Nov 29 11:52:59 2003 | |
58 | *************** | |
59 | *** 49,55 **** | |
60 | CNCB *callback; | |
61 | void *data; | |
62 | struct in_addr in_addr; | |
63 | - int locks; | |
64 | int fd; | |
65 | int tries; | |
66 | int addrcount; | |
67 | --- 49,54 ---- | |
68 | *************** | |
69 | *** 272,278 **** | |
70 | cs->data = data; | |
71 | cbdataLock(cs->data); | |
72 | comm_add_close_handler(fd, commConnectFree, cs); | |
73 | - cs->locks++; | |
74 | ipcache_nbgethostbyname(host, commConnectDnsHandle, cs); | |
75 | } | |
76 | ||
77 | --- 271,276 ---- | |
78 | *************** | |
79 | *** 280,287 **** | |
80 | commConnectDnsHandle(const ipcache_addrs * ia, void *data) | |
81 | { | |
82 | ConnectStateData *cs = data; | |
83 | - assert(cs->locks == 1); | |
84 | - cs->locks--; | |
85 | if (ia == NULL) { | |
86 | debug(5, 3) ("commConnectDnsHandle: Unknown host: %s\n", cs->host); | |
87 | if (!dns_error_message) { | |
88 | --- 278,283 ---- | |
89 | *************** | |
90 | *** 398,403 **** | |
91 | --- 394,406 ---- | |
92 | return commResetFD(cs); | |
93 | } | |
94 | ||
95 | + static void | |
96 | + commReconnect(void *data) | |
97 | + { | |
98 | + ConnectStateData *cs = data; | |
99 | + ipcache_nbgethostbyname(cs->host, commConnectDnsHandle, cs); | |
100 | + } | |
101 | + | |
102 | /* Connect SOCK to specified DEST_PORT at DEST_HOST. */ | |
103 | static void | |
104 | commConnectHandle(int fd, void *data) | |
105 | *************** | |
106 | *** 425,432 **** | |
107 | if (Config.onoff.test_reachability) | |
108 | netdbDeleteAddrNetwork(cs->S.sin_addr); | |
109 | if (commRetryConnect(cs)) { | |
110 | ! cs->locks++; | |
111 | ! ipcache_nbgethostbyname(cs->host, commConnectDnsHandle, cs); | |
112 | } else { | |
113 | commConnectCallback(cs, COMM_ERR_CONNECT); | |
114 | } | |
115 | --- 428,434 ---- | |
116 | if (Config.onoff.test_reachability) | |
117 | netdbDeleteAddrNetwork(cs->S.sin_addr); | |
118 | if (commRetryConnect(cs)) { | |
119 | ! eventAdd("commReconnect", commReconnect, cs, cs->addrcount == 1 ? 0.05 : 0.0, 0); | |
120 | } else { | |
121 | commConnectCallback(cs, COMM_ERR_CONNECT); | |
122 | } | |
123 | Index: squid/src/forward.c | |
124 | diff -c squid/src/forward.c:1.82.2.4 squid/src/forward.c:1.82.2.5 | |
125 | *** squid/src/forward.c:1.82.2.4 Wed Aug 6 07:49:01 2003 | |
126 | --- squid/src/forward.c Sat Nov 29 11:53:00 2003 | |
127 | *************** | |
128 | *** 136,141 **** | |
129 | --- 136,143 ---- | |
130 | return 0; | |
131 | if (fwdState->n_tries > 10) | |
132 | return 0; | |
133 | + if (fwdState->origin_tries > 2) | |
134 | + return 0; | |
135 | if (squid_curtime - fwdState->start > Config.Timeout.connect) | |
136 | return 0; | |
137 | if (fwdState->flags.dont_retry) | |
138 | *************** | |
139 | *** 180,185 **** | |
140 | --- 182,188 ---- | |
141 | assert(fwdState->server_fd == fd); | |
142 | fwdState->server_fd = -1; | |
143 | if (fwdCheckRetry(fwdState)) { | |
144 | + int originserver = (fwdState->servers->peer == NULL); | |
145 | debug(17, 3) ("fwdServerClosed: re-forwarding (%d tries, %d secs)\n", | |
146 | fwdState->n_tries, | |
147 | (int) (squid_curtime - fwdState->start)); | |
148 | *************** | |
149 | *** 197,206 **** | |
150 | /* Use next. The last "direct" entry is retried multiple times */ | |
151 | fwdState->servers = fs->next; | |
152 | fwdServerFree(fs); | |
153 | } | |
154 | } | |
155 | ! /* use eventAdd to break potential call sequence loops */ | |
156 | ! eventAdd("fwdConnectStart", fwdConnectStart, fwdState, 0.0, 0); | |
157 | return; | |
158 | } | |
159 | if (!fwdState->err && shutting_down) { | |
160 | --- 200,210 ---- | |
161 | /* Use next. The last "direct" entry is retried multiple times */ | |
162 | fwdState->servers = fs->next; | |
163 | fwdServerFree(fs); | |
164 | + originserver = 0; | |
165 | } | |
166 | } | |
167 | ! /* use eventAdd to break potential call sequence loops and to slow things down a little */ | |
168 | ! eventAdd("fwdConnectStart", fwdConnectStart, fwdState, originserver ? 0.05 : 0.005, 0); | |
169 | return; | |
170 | } | |
171 | if (!fwdState->err && shutting_down) { | |
172 | *************** | |
173 | *** 387,392 **** | |
174 | --- 391,398 ---- | |
175 | debug(17, 3) ("fwdConnectStart: reusing pconn FD %d\n", fd); | |
176 | fwdState->server_fd = fd; | |
177 | fwdState->n_tries++; | |
178 | + if (!fs->peer) | |
179 | + fwdState->origin_tries++; | |
180 | comm_add_close_handler(fd, fwdServerClosed, fwdState); | |
181 | fwdConnectDone(fd, COMM_OK, fwdState); | |
182 | return; | |
183 | *************** | |
184 | *** 418,423 **** | |
185 | --- 424,431 ---- | |
186 | } | |
187 | fwdState->server_fd = fd; | |
188 | fwdState->n_tries++; | |
189 | + if (!fs->peer) | |
190 | + fwdState->origin_tries++; | |
191 | /* | |
192 | * stats.conn_open is used to account for the number of | |
193 | * connections that we have open to the peer, so we can limit | |
194 | *************** | |
195 | *** 553,558 **** | |
196 | --- 561,568 ---- | |
197 | return 0; | |
198 | } | |
199 | if (fwdState->n_tries > 9) | |
200 | + return 0; | |
201 | + if (fwdState->origin_tries > 1) | |
202 | return 0; | |
203 | if (fwdState->request->flags.body_sent) | |
204 | return 0; | |
205 | Index: squid/src/neighbors.c | |
206 | diff -c squid/src/neighbors.c:1.299.2.3 squid/src/neighbors.c:1.299.2.4 | |
207 | *** squid/src/neighbors.c:1.299.2.3 Tue Aug 12 18:28:19 2003 | |
208 | --- squid/src/neighbors.c Sat Nov 29 11:53:00 2003 | |
209 | *************** | |
210 | *** 48,55 **** | |
211 | static void neighborCountIgnored(peer *); | |
212 | static void peerRefreshDNS(void *); | |
213 | static IPH peerDNSConfigure; | |
214 | ! static void peerProbeConnect(peer *); | |
215 | ! static IPH peerProbeConnect2; | |
216 | static CNCB peerProbeConnectDone; | |
217 | static void peerCountMcastPeersDone(void *data); | |
218 | static void peerCountMcastPeersStart(void *data); | |
219 | --- 48,54 ---- | |
220 | static void neighborCountIgnored(peer *); | |
221 | static void peerRefreshDNS(void *); | |
222 | static IPH peerDNSConfigure; | |
223 | ! static int peerProbeConnect(peer *); | |
224 | static CNCB peerProbeConnectDone; | |
225 | static void peerCountMcastPeersDone(void *data); | |
226 | static void peerCountMcastPeersStart(void *data); | |
227 | *************** | |
228 | *** 590,609 **** | |
229 | if (!p->digest) { | |
230 | debug(15, 5) ("peerDigestLookup: gone!\n"); | |
231 | return LOOKUP_NONE; | |
232 | - } else if (!peerHTTPOkay(p, request)) { | |
233 | - debug(15, 5) ("peerDigestLookup: !peerHTTPOkay\n"); | |
234 | - return LOOKUP_NONE; | |
235 | - } else if (p->digest->flags.usable) { | |
236 | - debug(15, 5) ("peerDigestLookup: usable\n"); | |
237 | - /* fall through; put here to have common case on top */ ; | |
238 | } else if (!p->digest->flags.needed) { | |
239 | debug(15, 5) ("peerDigestLookup: note need\n"); | |
240 | peerDigestNeeded(p->digest); | |
241 | return LOOKUP_NONE; | |
242 | ! } else { | |
243 | debug(15, 5) ("peerDigestLookup: !ready && %srequested\n", | |
244 | p->digest->flags.requested ? "" : "!"); | |
245 | return LOOKUP_NONE; | |
246 | } | |
247 | debug(15, 5) ("peerDigestLookup: OK to lookup peer %s\n", p->host); | |
248 | assert(p->digest->cd); | |
249 | --- 589,605 ---- | |
250 | if (!p->digest) { | |
251 | debug(15, 5) ("peerDigestLookup: gone!\n"); | |
252 | return LOOKUP_NONE; | |
253 | } else if (!p->digest->flags.needed) { | |
254 | debug(15, 5) ("peerDigestLookup: note need\n"); | |
255 | peerDigestNeeded(p->digest); | |
256 | return LOOKUP_NONE; | |
257 | ! } else if (!p->digest->flags.usable) { | |
258 | debug(15, 5) ("peerDigestLookup: !ready && %srequested\n", | |
259 | p->digest->flags.requested ? "" : "!"); | |
260 | return LOOKUP_NONE; | |
261 | + } else if (!peerHTTPOkay(p, request)) { | |
262 | + debug(15, 5) ("peerDigestLookup: !peerHTTPOkay\n"); | |
263 | + return LOOKUP_NONE; | |
264 | } | |
265 | debug(15, 5) ("peerDigestLookup: OK to lookup peer %s\n", p->host); | |
266 | assert(p->digest->cd); | |
267 | *************** | |
268 | *** 935,942 **** | |
269 | neighborUp(const peer * p) | |
270 | { | |
271 | if (!p->tcp_up) { | |
272 | ! peerProbeConnect((peer *) p); | |
273 | ! return 0; | |
274 | } | |
275 | if (p->options.no_query) | |
276 | return 1; | |
277 | --- 931,938 ---- | |
278 | neighborUp(const peer * p) | |
279 | { | |
280 | if (!p->tcp_up) { | |
281 | ! if (!peerProbeConnect((peer *) p)) | |
282 | ! return 0; | |
283 | } | |
284 | if (p->options.no_query) | |
285 | return 1; | |
286 | *************** | |
287 | *** 1042,1056 **** | |
288 | eventAddIsh("peerRefreshDNS", peerRefreshDNS, NULL, 3600.0, 1); | |
289 | } | |
290 | ||
291 | ! void | |
292 | ! peerConnectFailed(peer * p) | |
293 | { | |
294 | p->stats.last_connect_failure = squid_curtime; | |
295 | if (!p->tcp_up) { | |
296 | debug(15, 2) ("TCP connection to %s/%d dead\n", p->host, p->http_port); | |
297 | return; | |
298 | } | |
299 | - debug(15, 1) ("TCP connection to %s/%d failed\n", p->host, p->http_port); | |
300 | p->tcp_up--; | |
301 | if (!p->tcp_up) { | |
302 | debug(15, 1) ("Detected DEAD %s: %s/%d/%d\n", | |
303 | --- 1038,1051 ---- | |
304 | eventAddIsh("peerRefreshDNS", peerRefreshDNS, NULL, 3600.0, 1); | |
305 | } | |
306 | ||
307 | ! static void | |
308 | ! peerConnectFailedSilent(peer * p) | |
309 | { | |
310 | p->stats.last_connect_failure = squid_curtime; | |
311 | if (!p->tcp_up) { | |
312 | debug(15, 2) ("TCP connection to %s/%d dead\n", p->host, p->http_port); | |
313 | return; | |
314 | } | |
315 | p->tcp_up--; | |
316 | if (!p->tcp_up) { | |
317 | debug(15, 1) ("Detected DEAD %s: %s/%d/%d\n", | |
318 | *************** | |
319 | *** 1061,1066 **** | |
320 | --- 1056,1068 ---- | |
321 | } | |
322 | ||
323 | void | |
324 | + peerConnectFailed(peer * p) | |
325 | + { | |
326 | + debug(15, 1) ("TCP connection to %s/%d failed\n", p->host, p->http_port); | |
327 | + peerConnectFailedSilent(p); | |
328 | + } | |
329 | + | |
330 | + void | |
331 | peerConnectSucceded(peer * p) | |
332 | { | |
333 | if (!p->tcp_up) { | |
334 | *************** | |
335 | *** 1073,1107 **** | |
336 | p->tcp_up = PEER_TCP_MAGIC_COUNT; | |
337 | } | |
338 | ||
339 | /* | |
340 | * peerProbeConnect will be called on dead peers by neighborUp | |
341 | */ | |
342 | ! static void | |
343 | peerProbeConnect(peer * p) | |
344 | { | |
345 | int fd; | |
346 | if (p->test_fd != -1) | |
347 | ! return; /* probe already running */ | |
348 | ! if (squid_curtime - p->stats.last_connect_probe < Config.Timeout.connect) | |
349 | ! return; /* don't probe to often */ | |
350 | fd = comm_open(SOCK_STREAM, 0, getOutgoingAddr(NULL), | |
351 | 0, COMM_NONBLOCKING, p->host); | |
352 | if (fd < 0) | |
353 | ! return; | |
354 | p->test_fd = fd; | |
355 | p->stats.last_connect_probe = squid_curtime; | |
356 | - ipcache_nbgethostbyname(p->host, peerProbeConnect2, p); | |
357 | - } | |
358 | - | |
359 | - static void | |
360 | - peerProbeConnect2(const ipcache_addrs * ianotused, void *data) | |
361 | - { | |
362 | - peer *p = data; | |
363 | commConnectStart(p->test_fd, | |
364 | p->host, | |
365 | p->http_port, | |
366 | peerProbeConnectDone, | |
367 | p); | |
368 | } | |
369 | ||
370 | static void | |
371 | --- 1075,1116 ---- | |
372 | p->tcp_up = PEER_TCP_MAGIC_COUNT; | |
373 | } | |
374 | ||
375 | + static void | |
376 | + peerProbeConnectTimeout(int fd, void *data) | |
377 | + { | |
378 | + peer *p = data; | |
379 | + comm_close(fd); | |
380 | + p->test_fd = -1; | |
381 | + peerConnectFailedSilent(p); | |
382 | + } | |
383 | + | |
384 | /* | |
385 | * peerProbeConnect will be called on dead peers by neighborUp | |
386 | */ | |
387 | ! static int | |
388 | peerProbeConnect(peer * p) | |
389 | { | |
390 | int fd; | |
391 | + time_t ctimeout = p->connect_timeout > 0 ? p->connect_timeout | |
392 | + : Config.Timeout.peer_connect; | |
393 | + int ret = squid_curtime - p->stats.last_connect_failure > ctimeout * 10; | |
394 | if (p->test_fd != -1) | |
395 | ! return ret; /* probe already running */ | |
396 | ! if (squid_curtime - p->stats.last_connect_probe == 0) | |
397 | ! return ret; /* don't probe to often */ | |
398 | fd = comm_open(SOCK_STREAM, 0, getOutgoingAddr(NULL), | |
399 | 0, COMM_NONBLOCKING, p->host); | |
400 | if (fd < 0) | |
401 | ! return ret; | |
402 | ! commSetTimeout(fd, ctimeout, peerProbeConnectTimeout, p); | |
403 | p->test_fd = fd; | |
404 | p->stats.last_connect_probe = squid_curtime; | |
405 | commConnectStart(p->test_fd, | |
406 | p->host, | |
407 | p->http_port, | |
408 | peerProbeConnectDone, | |
409 | p); | |
410 | + return ret; | |
411 | } | |
412 | ||
413 | static void | |
414 | *************** | |
415 | *** 1111,1117 **** | |
416 | if (status == COMM_OK) { | |
417 | peerConnectSucceded(p); | |
418 | } else { | |
419 | ! peerConnectFailed(p); | |
420 | } | |
421 | comm_close(fd); | |
422 | p->test_fd = -1; | |
423 | --- 1120,1126 ---- | |
424 | if (status == COMM_OK) { | |
425 | peerConnectSucceded(p); | |
426 | } else { | |
427 | ! peerConnectFailedSilent(p); | |
428 | } | |
429 | comm_close(fd); | |
430 | p->test_fd = -1; | |
431 | Index: squid/src/structs.h | |
432 | diff -c squid/src/structs.h:1.408.2.15 squid/src/structs.h:1.408.2.16 | |
433 | *** squid/src/structs.h:1.408.2.15 Wed Oct 29 17:01:52 2003 | |
434 | --- squid/src/structs.h Sat Nov 29 11:53:00 2003 | |
435 | *************** | |
436 | *** 1959,1964 **** | |
437 | --- 1959,1965 ---- | |
438 | ErrorState *err; | |
439 | time_t start; | |
440 | int n_tries; | |
441 | + int origin_tries; | |
442 | #if WIP_FWD_LOG | |
443 | http_status last_status; | |
444 | #endif |