Bug 824851: Fixed RUN_ON_THREAD to not dispatch on own thread. r=ekr
authorJan-Ivar Bruaroey <jib@mozilla.com>
Fri, 28 Dec 2012 15:42:53 -0500
changeset 126479 e3a7b9905aaf77f27ef59c22edbd52528c78bae8
parent 126478 908d47fb422bf052cec0eaa6c453dd496d907a8e
child 126480 288b327769f0d80728b10956b3787bccde897b55
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersekr
bugs824851
milestone20.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 824851: Fixed RUN_ON_THREAD to not dispatch on own thread. r=ekr
media/mtransport/runnable_utils.h
--- a/media/mtransport/runnable_utils.h
+++ b/media/mtransport/runnable_utils.h
@@ -36,21 +36,26 @@ class runnable_args_base : public nsRunn
 // 
 // All of these template functions return a Runnable* which can be passed
 // to Dispatch().
 #include "runnable_utils_generated.h"
 
 // Temporary hack. Really we want to have a template which will do this
 static inline nsresult RUN_ON_THREAD(nsIEventTarget *thread, nsIRunnable *runnable, uint32_t flags) {
   RefPtr<nsIRunnable> runnable_ref(runnable);
-  
-  if (thread && (thread != nsRefPtr<nsIThread>(do_GetCurrentThread()))) {
-    return thread->Dispatch(runnable_ref, flags);
+  if (thread) {
+    bool on;
+    nsresult rv;
+    rv = thread->IsOnCurrentThread(&on);
+    MOZ_ASSERT(NS_SUCCEEDED(rv));
+    NS_ENSURE_SUCCESS(rv, rv);
+    if(!on) {
+      return thread->Dispatch(runnable_ref, flags);
+    }
   }
-
   return runnable_ref->Run();
 }
 
 #define ASSERT_ON_THREAD(t) do {                \
     if (t) {                                    \
       bool on;                                    \
       nsresult rv;                                \
       rv = t->IsOnCurrentThread(&on);             \