diff --git a/dom/bluetooth/BluetoothHfpManager.cpp b/dom/bluetooth/BluetoothHfpManager.cpp index 3b98b2f4ff4..2b54d987a44 100644 --- a/dom/bluetooth/BluetoothHfpManager.cpp +++ b/dom/bluetooth/BluetoothHfpManager.cpp @@ -202,7 +202,6 @@ BluetoothHfpManager::Get() NS_ENSURE_TRUE(manager, nullptr); if (!manager->Init()) { - manager->Cleanup(); return nullptr; } @@ -334,7 +333,7 @@ BluetoothHfpManager::HandleShutdown() { MOZ_ASSERT(NS_IsMainThread()); gInShutdown = true; - Cleanup(); + CloseSocket(); gBluetoothHfpManager = nullptr; return NS_OK; } diff --git a/dom/bluetooth/BluetoothScoManager.cpp b/dom/bluetooth/BluetoothScoManager.cpp index a30a456b4f3..ac79f7afcef 100644 --- a/dom/bluetooth/BluetoothScoManager.cpp +++ b/dom/bluetooth/BluetoothScoManager.cpp @@ -108,7 +108,6 @@ BluetoothScoManager::Get() NS_ENSURE_TRUE(manager, nullptr); if (!manager->Init()) { - manager->Cleanup(); return nullptr; } @@ -142,7 +141,7 @@ BluetoothScoManager::HandleShutdown() { MOZ_ASSERT(NS_IsMainThread()); gInShutdown = true; - Cleanup(); + CloseSocket(); gBluetoothScoManager = nullptr; return NS_OK; } diff --git a/ipc/unixsocket/UnixSocket.cpp b/ipc/unixsocket/UnixSocket.cpp index fd1c88215d7..90595d2c1f6 100644 --- a/ipc/unixsocket/UnixSocket.cpp +++ b/ipc/unixsocket/UnixSocket.cpp @@ -118,7 +118,8 @@ public: void PrepareRemoval() { - mConsumer.forget(); + mTask = nullptr; + mCurrentTaskIsCanceled = true; } /** @@ -229,6 +230,7 @@ private: static void DestroyImpl(UnixSocketImpl* impl) { + MOZ_ASSERT(impl); delete impl; } @@ -498,13 +500,15 @@ UnixSocketConsumer::CloseSocket() if (!mImpl) { return; } + UnixSocketImpl* impl = mImpl; + mImpl->mConsumer.forget(); + mImpl = nullptr; // To make sure the owner doesn't die on the IOThread, remove pointer here - mImpl->PrepareRemoval(); // Line it up to be destructed on the IO Thread // Kill our pointer to it XRE_GetIOMessageLoop()->PostTask(FROM_HERE, NewRunnableFunction(DestroyImpl, - mImpl.forget())); + impl)); } void diff --git a/ipc/unixsocket/UnixSocket.h b/ipc/unixsocket/UnixSocket.h index 7dc01551f63..4362d7abde3 100644 --- a/ipc/unixsocket/UnixSocket.h +++ b/ipc/unixsocket/UnixSocket.h @@ -173,7 +173,7 @@ public: */ void CancelSocketTask(); private: - nsAutoPtr mImpl; + UnixSocketImpl* mImpl; }; } // namespace ipc