tags 335660 = patch pending thanks ----- Forwarded message from "SourceForge.net" <[EMAIL PROTECTED]> -----
Comment By: Fabian Keil (fabiankeil) Date: 2006-07-29 22:09 Message: Logged In: YES user_id=875547 While it is a proxy error message, it is usually not the result of "an invalid response from the upstream server" (I'm not sure if it ever is). Most of the time it's because gethostbyname returned TRY_AGAIN (DNS timeout) or HOST_NOT_FOUND (if the site really doesn't exist). Both are valid responses and the upstream server had nothing to do with it (at least I think that "upstream server" doesn't include the DNS server here). Privoxy also uses "404 No such domain" if socks4a is used and the connection request is rejected. Returning 404 isn't perfect, but a reasonable choice. Quoting RFC 2616: "This status code is commonly used ... or when no other response is applicable." There are status codes available which would fit better in some cases (for example 504 in case of a DNS timeout), but as long as Privoxy doesn't differentiate the reasons, 404 is the best choice. 502 is incorrect most of the time, maybe always. In the bug tracker you linked to, Carl Fink wrote: "In these cases it takes up to 5 reloads of the page until privoxy can be made to access the page." Most likely that's because the browser cached Privoxy's error message and later revalidated it against the real server. The problem is described in more detail at: http://www.fabiankeil.de/sourcecode/privoxy/ The linked patch should mitigate his DNS problems and fix the caching problem entirely. Fabian ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=111118&aid=1531023&group_id=11118 ----- End forwarded message ----- I extracted the attached patch from Fabians patch, which implements 10 retries of DNS requests. This should solve the DNS problems mentioned in Bug#335660. Tschoeeee Roland
#! /bin/sh /usr/share/dpatch/dpatch-run ## 18_dns_retry.dpatch by Fabian Keil <[EMAIL PROTECTED]> ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Retries DNS queries 10 times before giving up. ## DP: Extracted from http://www.fabiankeil.de/sourcecode/privoxy/ @DPATCH@ diff -urNad privoxy~/jbsockets.c privoxy/jbsockets.c --- privoxy~/jbsockets.c +++ privoxy/jbsockets.c @@ -780,6 +780,7 @@ { struct sockaddr_in inaddr; struct hostent *hostp; + unsigned int dns_retries = 0; #if defined(HAVE_GETHOSTBYNAME_R_6_ARGS) || defined(HAVE_GETHOSTBYNAME_R_5_ARGS) || defined(HAVE_GETHOSTBYNAME_R_3_ARGS) struct hostent result; #if defined(HAVE_GETHOSTBYNAME_R_6_ARGS) || defined(HAVE_GETHOSTBYNAME_R_5_ARGS) @@ -819,7 +820,12 @@ hostp = gethostbyname(host); pthread_mutex_unlock(&gethostbyname_mutex); #else - hostp = gethostbyname(host); + while ( NULL == (hostp = gethostbyname(host)) + && (h_errno == TRY_AGAIN) && (dns_retries++ < 10) ) + { + log_error(LOG_LEVEL_ERROR, "%u. timeout while trying to resolve %s. Trying again.", + dns_retries, host); + } #endif /* def HAVE_GETHOSTBYNAME_R_(6|5|3)_ARGS */ /* * On Mac OSX, if a domain exists but doesn't have a type A