Bug 1044245: don't track Windows IPC stack frames on non-gui threads r=bsmedberg
This commit is contained in:
@@ -642,6 +642,11 @@ MessageChannel::SyncStackFrame::SyncStackFrame(MessageChannel* channel, bool int
|
|||||||
, mPrev(mChannel->mTopFrame)
|
, mPrev(mChannel->mTopFrame)
|
||||||
, mStaticPrev(sStaticTopFrame)
|
, mStaticPrev(sStaticTopFrame)
|
||||||
{
|
{
|
||||||
|
// Only track stack frames when we are on the gui thread.
|
||||||
|
if (GetCurrentThreadId() != gUIThreadId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mChannel->mTopFrame = this;
|
mChannel->mTopFrame = this;
|
||||||
sStaticTopFrame = this;
|
sStaticTopFrame = this;
|
||||||
|
|
||||||
@@ -654,6 +659,10 @@ MessageChannel::SyncStackFrame::SyncStackFrame(MessageChannel* channel, bool int
|
|||||||
|
|
||||||
MessageChannel::SyncStackFrame::~SyncStackFrame()
|
MessageChannel::SyncStackFrame::~SyncStackFrame()
|
||||||
{
|
{
|
||||||
|
if (GetCurrentThreadId() != gUIThreadId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
NS_ASSERTION(this == mChannel->mTopFrame,
|
NS_ASSERTION(this == mChannel->mTopFrame,
|
||||||
"Mismatched interrupt stack frames");
|
"Mismatched interrupt stack frames");
|
||||||
NS_ASSERTION(this == sStaticTopFrame,
|
NS_ASSERTION(this == sStaticTopFrame,
|
||||||
@@ -692,6 +701,8 @@ MessageChannel::NotifyGeckoEventDispatch()
|
|||||||
void
|
void
|
||||||
MessageChannel::ProcessNativeEventsInInterruptCall()
|
MessageChannel::ProcessNativeEventsInInterruptCall()
|
||||||
{
|
{
|
||||||
|
NS_ASSERTION(GetCurrentThreadId() == gUIThreadId,
|
||||||
|
"Shouldn't be on a non-main thread in here!");
|
||||||
if (!mTopFrame) {
|
if (!mTopFrame) {
|
||||||
NS_ERROR("Spin logic error: no Interrupt frame");
|
NS_ERROR("Spin logic error: no Interrupt frame");
|
||||||
return;
|
return;
|
||||||
@@ -775,6 +786,10 @@ MessageChannel::WaitForSyncNotify()
|
|||||||
|
|
||||||
MOZ_ASSERT(gUIThreadId, "InitUIThread was not called!");
|
MOZ_ASSERT(gUIThreadId, "InitUIThread was not called!");
|
||||||
|
|
||||||
|
// We jump through a lot of unique hoops in dealing with Windows message
|
||||||
|
// trapping to prevent re-entrancy when we are blocked waiting on a sync
|
||||||
|
// reply or new rpc in-call. However none of this overhead is needed when
|
||||||
|
// we aren't on the main (gui) thread.
|
||||||
if (GetCurrentThreadId() != gUIThreadId) {
|
if (GetCurrentThreadId() != gUIThreadId) {
|
||||||
PRIntervalTime timeout = (kNoTimeout == mTimeoutMs) ?
|
PRIntervalTime timeout = (kNoTimeout == mTimeoutMs) ?
|
||||||
PR_INTERVAL_NO_TIMEOUT :
|
PR_INTERVAL_NO_TIMEOUT :
|
||||||
@@ -795,9 +810,13 @@ MessageChannel::WaitForSyncNotify()
|
|||||||
|
|
||||||
// If the timeout didn't expire, we know we received an event. The
|
// If the timeout didn't expire, we know we received an event. The
|
||||||
// converse is not true.
|
// converse is not true.
|
||||||
return WaitResponse(timeout == PR_INTERVAL_NO_TIMEOUT ? false : IsTimeoutExpired(waitStart, timeout));
|
return WaitResponse(timeout == PR_INTERVAL_NO_TIMEOUT ?
|
||||||
|
false : IsTimeoutExpired(waitStart, timeout));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_ASSERTION(GetCurrentThreadId() == gUIThreadId,
|
||||||
|
"Shouldn't be on a non-main thread in here!");
|
||||||
|
|
||||||
NS_ASSERTION(mTopFrame && !mTopFrame->mInterrupt,
|
NS_ASSERTION(mTopFrame && !mTopFrame->mInterrupt,
|
||||||
"Top frame is not a sync frame!");
|
"Top frame is not a sync frame!");
|
||||||
|
|
||||||
@@ -919,10 +938,16 @@ MessageChannel::WaitForInterruptNotify()
|
|||||||
|
|
||||||
MOZ_ASSERT(gUIThreadId, "InitUIThread was not called!");
|
MOZ_ASSERT(gUIThreadId, "InitUIThread was not called!");
|
||||||
|
|
||||||
|
// Re-use sync notification wait code when we aren't on the
|
||||||
|
// gui thread, which bypasses the gui thread hoops we jump
|
||||||
|
// through in dealing with Windows messaging.
|
||||||
if (GetCurrentThreadId() != gUIThreadId) {
|
if (GetCurrentThreadId() != gUIThreadId) {
|
||||||
return WaitForSyncNotify();
|
return WaitForSyncNotify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_ASSERTION(GetCurrentThreadId() == gUIThreadId,
|
||||||
|
"Shouldn't be on a non-main thread in here!");
|
||||||
|
|
||||||
if (!InterruptStackDepth()) {
|
if (!InterruptStackDepth()) {
|
||||||
// There is currently no way to recover from this condition.
|
// There is currently no way to recover from this condition.
|
||||||
NS_RUNTIMEABORT("StackDepth() is 0 in call to MessageChannel::WaitForNotify!");
|
NS_RUNTIMEABORT("StackDepth() is 0 in call to MessageChannel::WaitForNotify!");
|
||||||
|
|||||||
Reference in New Issue
Block a user