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

Unified Diff: jingle/notifier/communicator/login.cc

Issue 3040052: Make libjingle resolve DNS synchronously to avoid crashes. (Closed)
Patch Set: Created 10 years, 4 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: jingle/notifier/communicator/login.cc
diff --git a/jingle/notifier/communicator/login.cc b/jingle/notifier/communicator/login.cc
index 7cf4952e092ddef459993932ec0872be6297172b..263f67e90a4499a2b8e4804c3e03b943aa8c3aaa 100644
--- a/jingle/notifier/communicator/login.cc
+++ b/jingle/notifier/communicator/login.cc
@@ -314,8 +314,10 @@ void Login::CheckConnection() {
LOG(INFO) << "Checking connection";
talk_base::PhysicalSocketServer physical;
scoped_ptr<talk_base::Socket> socket(physical.CreateSocket(SOCK_STREAM));
- bool alive =
- !socket->Connect(talk_base::SocketAddress("talk.google.com", 5222));
+ talk_base::SocketAddress addr("talk.google.com", 5222);
+ // Resolve synchronously to avoid weirdness with libjingle's async
+ // DNS resolver.
+ bool alive = addr.ResolveIP() && (socket->Connect(addr) == 0);
LOG(INFO) << "Network is " << (alive ? "alive" : "not alive");
if (alive) {
// Our connection is up. If we have a disconnect timer going,
« 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