Bug 610381 part A - Propagate errors thrown during synchronous dispatch of nsIRunnables, r=bz
authorBenjamin Smedberg <benjamin@smedbergs.us>
Wed, 17 Nov 2010 15:58:48 -0500
changeset 57666 3862e43372ba848dc57e0d1702100ae06d0d672b
parent 57665 b5c6ae71b2eb913394d3e54ff852ef4f32a90776
child 57667 a86f1ab3f3dba57e18c5f09b39b60f4321100103
push id17031
push userbsmedberg@mozilla.com
push dateWed, 17 Nov 2010 21:02:34 +0000
treeherdermozilla-central@a86f1ab3f3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs610381
milestone2.0b8pre
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 610381 part A - Propagate errors thrown during synchronous dispatch of nsIRunnables, r=bz
xpcom/threads/nsThread.cpp
xpcom/threads/nsThread.h
--- a/xpcom/threads/nsThread.cpp
+++ b/xpcom/threads/nsThread.cpp
@@ -421,17 +421,17 @@ nsThread::Dispatch(nsIRunnable *event, P
       return NS_ERROR_OUT_OF_MEMORY;
     nsresult rv = PutEvent(wrapper);
     // Don't wait for the event to finish if we didn't dispatch it...
     if (NS_FAILED(rv))
       return rv;
 
     while (wrapper->IsPending())
       NS_ProcessNextEvent(thread);
-    return rv;
+    return wrapper->Result();
   }
 
   NS_ASSERTION(flags == NS_DISPATCH_NORMAL, "unexpected dispatch flags");
   return PutEvent(event);
 }
 
 NS_IMETHODIMP
 nsThread::IsOnCurrentThread(PRBool *result)
@@ -750,17 +750,17 @@ nsThread::GetRecursionDepth(PRUint32 *de
 }
 
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
 nsThreadSyncDispatch::Run()
 {
   if (mSyncTask) {
-    mSyncTask->Run();
+    mResult = mSyncTask->Run();
     mSyncTask = nsnull;
     // unblock the origin thread
     mOrigin->Dispatch(this, NS_DISPATCH_NORMAL);
   }
   return NS_OK;
 }
 
 nsresult
--- a/xpcom/threads/nsThread.h
+++ b/xpcom/threads/nsThread.h
@@ -149,23 +149,28 @@ private:
   PRPackedBool mEventsAreDoomed;
 };
 
 //-----------------------------------------------------------------------------
 
 class nsThreadSyncDispatch : public nsRunnable {
 public:
   nsThreadSyncDispatch(nsIThread *origin, nsIRunnable *task)
-    : mOrigin(origin), mSyncTask(task) {
+    : mOrigin(origin), mSyncTask(task), mResult(NS_ERROR_NOT_INITIALIZED) {
   }
 
   PRBool IsPending() {
     return mSyncTask != nsnull;
   }
 
+  nsresult Result() {
+    return mResult;
+  }
+
 private:
   NS_DECL_NSIRUNNABLE
 
   nsCOMPtr<nsIThread> mOrigin;
   nsCOMPtr<nsIRunnable> mSyncTask;
+  nsresult mResult;
 };
 
 #endif  // nsThread_h__