From 54433e72aabb2b01aa1c5c7b6a2ba91c2c01b348 Mon Sep 17 00:00:00 2001 From: Taylor Brandstetter Date: Wed, 29 Jun 2016 10:10:31 -0700 Subject: [PATCH] Fixing flakiness of TestDetectUnresolvedProxy. If the AutoDetectProxy timed out resolving one address, it was attempting to use the same resolver to resolve the next address, which would always result in an assertion. This happened recently a couple times on the Windows DrMemory bot because of its slowness. TBR=pthatcher@webrtc.org Review URL: https://codereview.webrtc.org/2104203002 . Cr-Commit-Position: refs/heads/master@{#13326} --- webrtc/base/autodetectproxy.cc | 15 ++++++++++++++- webrtc/base/autodetectproxy.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) 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();