bug 943149 - nsHttpChannel::ResolveProxy may break AsyncOpen contract r=mayhemer
authorPatrick McManus <mcmanus@ducksong.com>
Fri, 29 Nov 2013 10:14:01 -0500
changeset 158131 3ed81454baf97bfcb2b9551f3b146598deedd43a
parent 158130 f4a802140bc7ec319cb7ba2b69afe3f516e35306
child 158132 f76604a4f0259e4ce4539853d3936777b80b4bf1
push id36913
push usermcmanus@ducksong.com
push dateFri, 29 Nov 2013 15:14:34 +0000
treeherdermozilla-inbound@3ed81454baf9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs943149
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 943149 - nsHttpChannel::ResolveProxy may break AsyncOpen contract r=mayhemer
netwerk/protocol/http/nsHttpChannel.cpp
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -4647,19 +4647,26 @@ nsHttpChannel::OnProxyAvailable(nsICance
         rv = NS_ERROR_NOT_AVAILABLE;
     }
     else {
         rv = BeginConnect();
     }
 
     if (NS_FAILED(rv)) {
         Cancel(rv);
-        DoNotifyListener();
-    }
-    return NS_OK;
+        // Calling OnStart/OnStop synchronously here would mean doing it before
+        // returning from AsyncOpen which is a contract violation. Do it async.
+        nsRefPtr<nsRunnableMethod<HttpBaseChannel> > event =
+            NS_NewRunnableMethod(this, &nsHttpChannel::DoNotifyListener);
+        rv = NS_DispatchToCurrentThread(event);
+        if (NS_FAILED(rv)) {
+            NS_WARNING("Failed To Dispatch DoNotifyListener");
+        }
+    }
+    return rv;
 }
 
 //-----------------------------------------------------------------------------
 // nsHttpChannel::nsIProxiedChannel
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
 nsHttpChannel::GetProxyInfo(nsIProxyInfo **result)