Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(534)

Unified Diff: net/base/host_resolver.cc

Issue 113904: Work around linux resolver problem where changes to resolv.conf go unnoticed in some distributions. (Closed)
Patch Set: Fixes as per Evan's review Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/host_resolver.cc
diff --git a/net/base/host_resolver.cc b/net/base/host_resolver.cc
index 873fdcd0399c242d085eacd2161c71c986625f23..23a1c00940e75c1c9a5fcf36ad386789eb48b3ad 100644
--- a/net/base/host_resolver.cc
+++ b/net/base/host_resolver.cc
@@ -11,6 +11,9 @@
#include <netdb.h>
#include <sys/socket.h>
#endif
+#if defined(OS_LINUX)
+#include <resolv.h>
+#endif
#include "base/message_loop.h"
#include "base/string_util.h"
@@ -72,6 +75,13 @@ static int HostResolverProc(
hints.ai_socktype = SOCK_STREAM;
int err = getaddrinfo(host.c_str(), port.c_str(), &hints, out);
+#if defined(OS_LINUX)
+ // If we fail, re-initialise the resolver just in case there have been any
+ // changes to /etc/resolv.conf and retry. See http://crbug.com/11380 for info.
+ if (err && !res_init())
darin (slow to review) 2009/05/27 19:23:11 please use res_ninit instead, which is threadsafe.
+ err = getaddrinfo(host.c_str(), port.c_str(), &hints, out);
+#endif
+
return err ? ERR_NAME_NOT_RESOLVED : OK;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698