diff --git a/webrtc/base/autodetectproxy.cc b/webrtc/base/autodetectproxy.cc index e563304fb5..3b4e1f4fc5 100644 --- a/webrtc/base/autodetectproxy.cc +++ b/webrtc/base/autodetectproxy.cc @@ -75,7 +75,7 @@ void AutoDetectProxy::OnMessage(Message *msg) { // If we can't resolve the proxy, skip straight to failure. Complete(PROXY_UNKNOWN); } else if (MSG_TIMEOUT == msg->message_id) { - OnCloseEvent(socket_, ETIMEDOUT); + OnTimeout(); } else { // This must be the ST_MSG_WORKER_DONE message that deletes the // AutoDetectProxy object. We have observed crashes within this stack that @@ -279,6 +279,19 @@ void AutoDetectProxy::OnReadEvent(AsyncSocket * socket) { Next(); } +void AutoDetectProxy::OnTimeout() { + LOG(LS_VERBOSE) << "Timed out waiting for AsyncResolver."; + // If a resolver timed out we shouldn't try to use it again since it may be + // in the middle of resolving the last address. + if (resolver_) { + resolver_->SignalDone.disconnect(this); + resolver_->Destroy(false); + resolver_ = nullptr; + } + ++next_; + Next(); +} + void AutoDetectProxy::OnCloseEvent(AsyncSocket * socket, int error) { LOG(LS_VERBOSE) << "AutoDetectProxy closed with error: " << error; ++next_; diff --git a/webrtc/base/autodetectproxy.h b/webrtc/base/autodetectproxy.h index 1bd523f8db..1788a0333d 100644 --- a/webrtc/base/autodetectproxy.h +++ b/webrtc/base/autodetectproxy.h @@ -70,6 +70,7 @@ class AutoDetectProxy : public SignalThread { void OnConnectEvent(AsyncSocket * socket); void OnReadEvent(AsyncSocket * socket); void OnCloseEvent(AsyncSocket * socket, int error); + void OnTimeout(); void OnResolveResult(AsyncResolverInterface* resolver); bool DoConnect();