diff --git a/ipc/glue/BackgroundImpl.cpp b/ipc/glue/BackgroundImpl.cpp index 9434aea02427..5e6166d2268a 100644 --- a/ipc/glue/BackgroundImpl.cpp +++ b/ipc/glue/BackgroundImpl.cpp @@ -318,7 +318,9 @@ class ChildImpl final : public BackgroundChildImpl struct ThreadLocalInfo { explicit ThreadLocalInfo(nsIIPCBackgroundChildCreateCallback* aCallback) +#ifdef DEBUG : mClosed(false) +#endif { mCallbacks.AppendElement(aCallback); } @@ -326,7 +328,9 @@ class ChildImpl final : public BackgroundChildImpl RefPtr mActor; nsTArray> mCallbacks; nsAutoPtr mConsumerThreadLocal; - DebugOnly mClosed; +#ifdef DEBUG + bool mClosed; +#endif }; // This is only modified on the main thread. It is a FIFO queue for actors @@ -338,12 +342,16 @@ class ChildImpl final : public BackgroundChildImpl static bool sShutdownHasStarted; #ifdef RELEASE_BUILD - DebugOnly mBoundThread; +#ifdef DEBUG + nsIThread* mBoundThread; +#endif #else nsIThread* mBoundThread; #endif - DebugOnly mActorDestroyed; +#ifdef DEBUG + bool mActorDestroyed; +#endif public: static bool @@ -375,7 +383,9 @@ public: ChildImpl() : mBoundThread(nullptr) +#ifdef DEBUG , mActorDestroyed(false) +#endif { AssertIsOnMainThread(); } @@ -1612,6 +1622,7 @@ ChildImpl::Shutdown() sShutdownHasStarted = true; +#ifdef DEBUG MOZ_ASSERT(sThreadLocalIndex != kBadThreadLocalIndex); auto threadLocalInfo = @@ -1621,6 +1632,7 @@ ChildImpl::Shutdown() MOZ_ASSERT(!threadLocalInfo->mClosed); threadLocalInfo->mClosed = true; } +#endif DebugOnly status = PR_SetThreadPrivate(sThreadLocalIndex, nullptr); MOZ_ASSERT(status == PR_SUCCESS); @@ -1747,8 +1759,10 @@ ChildImpl::CloseForCurrentThread() return; } +#ifdef DEBUG MOZ_ASSERT(!threadLocalInfo->mClosed); threadLocalInfo->mClosed = true; +#endif if (threadLocalInfo->mActor) { threadLocalInfo->mActor->FlushPendingInterruptQueue(); @@ -2092,8 +2106,10 @@ ChildImpl::ActorDestroy(ActorDestroyReason aWhy) { AssertIsOnBoundThread(); +#ifdef DEBUG MOZ_ASSERT(!mActorDestroyed); mActorDestroyed = true; +#endif BackgroundChildImpl::ActorDestroy(aWhy); } diff --git a/ipc/glue/FileDescriptor.cpp b/ipc/glue/FileDescriptor.cpp index dd8dbba1cd8a..e9d6ba2a0b54 100644 --- a/ipc/glue/FileDescriptor.cpp +++ b/ipc/glue/FileDescriptor.cpp @@ -29,13 +29,17 @@ using mozilla::ipc::FileDescriptor; FileDescriptor::FileDescriptor() -: mHandle(INVALID_HANDLE), mHandleCreatedByOtherProcess(false), - mHandleCreatedByOtherProcessWasUsed(false) + : mHandle(INVALID_HANDLE), mHandleCreatedByOtherProcess(false) +#ifdef DEBUG + , mHandleCreatedByOtherProcessWasUsed(false) +#endif { } FileDescriptor::FileDescriptor(PlatformHandleType aHandle) -: mHandle(INVALID_HANDLE), mHandleCreatedByOtherProcess(false), - mHandleCreatedByOtherProcessWasUsed(false) + : mHandle(INVALID_HANDLE), mHandleCreatedByOtherProcess(false) +#ifdef DEBUG + , mHandleCreatedByOtherProcessWasUsed(false) +#endif { DuplicateInCurrentProcess(aHandle); } diff --git a/ipc/glue/FileDescriptor.h b/ipc/glue/FileDescriptor.h index 8d94351d42ab..16e180ad4e5d 100644 --- a/ipc/glue/FileDescriptor.h +++ b/ipc/glue/FileDescriptor.h @@ -52,8 +52,10 @@ public: FileDescriptor(); FileDescriptor(const FileDescriptor& aOther) - : mHandleCreatedByOtherProcess(false), - mHandleCreatedByOtherProcessWasUsed(false) + : mHandleCreatedByOtherProcess(false) +#ifdef DEBUG + , mHandleCreatedByOtherProcessWasUsed(false) +#endif { // Don't use operator= here because that will call // CloseCurrentProcessHandle() on this (uninitialized) object. @@ -69,7 +71,9 @@ public: : mHandle(aPickle.fd) #endif , mHandleCreatedByOtherProcess(true) +#ifdef DEBUG , mHandleCreatedByOtherProcessWasUsed(false) +#endif { } ~FileDescriptor() @@ -102,9 +106,11 @@ public: PlatformHandleType PlatformHandle() const { +#ifdef DEBUG if (mHandleCreatedByOtherProcess) { mHandleCreatedByOtherProcessWasUsed = true; } +#endif return mHandle; } @@ -120,13 +126,17 @@ private: { if (aOther.mHandleCreatedByOtherProcess) { mHandleCreatedByOtherProcess = true; +#ifdef DEBUG mHandleCreatedByOtherProcessWasUsed = aOther.mHandleCreatedByOtherProcessWasUsed; +#endif mHandle = aOther.PlatformHandle(); } else { DuplicateInCurrentProcess(aOther.PlatformHandle()); mHandleCreatedByOtherProcess = false; +#ifdef DEBUG mHandleCreatedByOtherProcessWasUsed = false; +#endif } } @@ -147,9 +157,11 @@ private: // destruction. bool mHandleCreatedByOtherProcess; +#ifdef DEBUG // This is to ensure that we don't leak the handle (which is only possible // when we're in the receiving process). - mutable DebugOnly mHandleCreatedByOtherProcessWasUsed; + mutable bool mHandleCreatedByOtherProcessWasUsed; +#endif }; } // namespace ipc diff --git a/ipc/glue/MessagePump.cpp b/ipc/glue/MessagePump.cpp index a7b62a95e3ad..23ce47d29c90 100644 --- a/ipc/glue/MessagePump.cpp +++ b/ipc/glue/MessagePump.cpp @@ -32,7 +32,9 @@ using namespace mozilla::ipc; NS_DEFINE_NAMED_CID(NS_TIMER_CID); -static mozilla::DebugOnly gFirstDelegate; +#ifdef DEBUG +static MessagePump::Delegate* gFirstDelegate; +#endif namespace mozilla { namespace ipc { @@ -253,7 +255,9 @@ MessagePumpForChildProcess::Run(base::MessagePump::Delegate* aDelegate) { if (mFirstRun) { MOZ_ASSERT(aDelegate && !gFirstDelegate); +#ifdef DEBUG gFirstDelegate = aDelegate; +#endif mFirstRun = false; if (NS_FAILED(XRE_RunAppShell())) { @@ -261,7 +265,9 @@ MessagePumpForChildProcess::Run(base::MessagePump::Delegate* aDelegate) } MOZ_ASSERT(aDelegate && aDelegate == gFirstDelegate); +#ifdef DEBUG gFirstDelegate = nullptr; +#endif return; }