Bug 1189698 Potential race condition when shutting down the old player thread r=jimm
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Sat, 01 Aug 2015 14:03:43 +0100
changeset 255786 a48677d48570e2e6158f4d0f4ef012466320fbfb
parent 255785 768312f4d2810ab0413ff0a27cf1dc93c3079ff7
child 255787 02652b4367625e2771366b18bf2e95753c240e26
push id29155
push usercbook@mozilla.com
push dateMon, 03 Aug 2015 11:59:12 +0000
treeherdermozilla-central@b9f166a815b2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs1189698
milestone42.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 1189698 Potential race condition when shutting down the old player thread r=jimm
widget/windows/nsSound.cpp
--- a/widget/windows/nsSound.cpp
+++ b/widget/windows/nsSound.cpp
@@ -119,20 +119,19 @@ nsSound::nsSound()
 nsSound::~nsSound()
 {
   NS_ASSERTION(!mPlayerThread, "player thread is not null but should be");
   PurgeLastSound();
 }
 
 void nsSound::ShutdownOldPlayerThread()
 {
-  if (mPlayerThread) {
-    mPlayerThread->Shutdown();
-    mPlayerThread = nullptr;
-  }
+  nsCOMPtr<nsIThread> playerThread(mPlayerThread.forget());
+  if (playerThread)
+    playerThread->Shutdown();
 }
 
 void nsSound::PurgeLastSound() 
 {
   if (mLastSound) {
     // Halt any currently playing sound.
     ::PlaySound(nullptr, nullptr, SND_PURGE);