mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1049068 - Part 2: Store acquisition state as a bool instead of a CallStack. r=froydnj
--HG-- extra : rebase_source : 5e182b5261bc80f8df3f77040fa4bfcfe9839ffd
This commit is contained in:
parent
05f6577110
commit
138b553173
@ -42,16 +42,13 @@ BlockingResourceBase::DeadlockDetectorEntry::Print(
|
||||
const DDT::ResourceAcquisition& aFirstSeen,
|
||||
nsACString& aOut) const
|
||||
{
|
||||
CallStack lastAcquisition = mAcquisitionContext; // RACY, but benign
|
||||
bool maybeCurrentlyAcquired = (CallStack::kNone != lastAcquisition);
|
||||
|
||||
fprintf(stderr, "--- %s : %s",
|
||||
kResourceTypeName[mType], mName);
|
||||
aOut += BlockingResourceBase::kResourceTypeName[mType];
|
||||
aOut += " : ";
|
||||
aOut += mName;
|
||||
|
||||
if (maybeCurrentlyAcquired) {
|
||||
if (mAcquired) {
|
||||
fputs(" (currently acquired)\n", stderr);
|
||||
aOut += " (currently acquired)\n";
|
||||
}
|
||||
@ -59,7 +56,7 @@ BlockingResourceBase::DeadlockDetectorEntry::Print(
|
||||
fputs(" calling context\n", stderr);
|
||||
fputs(" [stack trace unavailable]\n", stderr);
|
||||
|
||||
return maybeCurrentlyAcquired;
|
||||
return mAcquired;
|
||||
}
|
||||
|
||||
|
||||
@ -137,11 +134,11 @@ BlockingResourceBase::Acquire(const CallStack& aCallContext)
|
||||
"FIXME bug 456272: annots. to allow Acquire()ing condvars");
|
||||
return;
|
||||
}
|
||||
NS_ASSERTION(mDDEntry->mAcquisitionContext == CallStack::kNone,
|
||||
NS_ASSERTION(!mDDEntry->mAcquired,
|
||||
"reacquiring already acquired resource");
|
||||
|
||||
ResourceChainAppend(ResourceChainFront());
|
||||
mDDEntry->mAcquisitionContext = aCallContext;
|
||||
mDDEntry->mAcquired = true;
|
||||
}
|
||||
|
||||
|
||||
@ -155,7 +152,7 @@ BlockingResourceBase::Release()
|
||||
}
|
||||
|
||||
BlockingResourceBase* chainFront = ResourceChainFront();
|
||||
NS_ASSERTION(chainFront && mDDEntry->mAcquisitionContext != CallStack::kNone,
|
||||
NS_ASSERTION(chainFront && mDDEntry->mAcquired,
|
||||
"Release()ing something that hasn't been Acquire()ed");
|
||||
|
||||
if (chainFront == this) {
|
||||
@ -181,7 +178,7 @@ BlockingResourceBase::Release()
|
||||
}
|
||||
}
|
||||
|
||||
mDDEntry->mAcquisitionContext = CallStack::kNone;
|
||||
mDDEntry->mAcquired = false;
|
||||
}
|
||||
|
||||
|
||||
@ -302,10 +299,10 @@ ReentrantMonitor::Wait(PRIntervalTime aInterval)
|
||||
|
||||
// save monitor state and reset it to empty
|
||||
int32_t savedEntryCount = mEntryCount;
|
||||
CallStack savedAcquisitionContext = GetAcquisitionContext();
|
||||
bool savedAcquisitionState = GetAcquisitionState();
|
||||
BlockingResourceBase* savedChainPrev = mChainPrev;
|
||||
mEntryCount = 0;
|
||||
SetAcquisitionContext(CallStack::kNone);
|
||||
SetAcquisitionState(false);
|
||||
mChainPrev = 0;
|
||||
|
||||
nsresult rv;
|
||||
@ -324,7 +321,7 @@ ReentrantMonitor::Wait(PRIntervalTime aInterval)
|
||||
|
||||
// restore saved state
|
||||
mEntryCount = savedEntryCount;
|
||||
SetAcquisitionContext(savedAcquisitionContext);
|
||||
SetAcquisitionState(savedAcquisitionState);
|
||||
mChainPrev = savedChainPrev;
|
||||
|
||||
return rv;
|
||||
@ -339,9 +336,9 @@ CondVar::Wait(PRIntervalTime aInterval)
|
||||
AssertCurrentThreadOwnsMutex();
|
||||
|
||||
// save mutex state and reset to empty
|
||||
CallStack savedAcquisitionContext = mLock->GetAcquisitionContext();
|
||||
bool savedAcquisitionState = mLock->GetAcquisitionState();
|
||||
BlockingResourceBase* savedChainPrev = mLock->mChainPrev;
|
||||
mLock->SetAcquisitionContext(CallStack::kNone);
|
||||
mLock->SetAcquisitionState(false);
|
||||
mLock->mChainPrev = 0;
|
||||
|
||||
// give up mutex until we're back from Wait()
|
||||
@ -349,7 +346,7 @@ CondVar::Wait(PRIntervalTime aInterval)
|
||||
PR_WaitCondVar(mCvar, aInterval) == PR_SUCCESS ? NS_OK : NS_ERROR_FAILURE;
|
||||
|
||||
// restore saved state
|
||||
mLock->SetAcquisitionContext(savedAcquisitionContext);
|
||||
mLock->SetAcquisitionState(savedAcquisitionState);
|
||||
mLock->mChainPrev = savedChainPrev;
|
||||
|
||||
return rv;
|
||||
|
@ -81,7 +81,7 @@ private:
|
||||
BlockingResourceType aType)
|
||||
: mName(aName)
|
||||
, mType(aType)
|
||||
, mAcquisitionContext(CallStack::kNone)
|
||||
, mAcquired(false)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(mName, "Name must be nonnull");
|
||||
}
|
||||
@ -129,11 +129,10 @@ private:
|
||||
**/
|
||||
BlockingResourceType mType;
|
||||
/**
|
||||
* mAcquisitionContext
|
||||
* The calling context from which this resource was acquired, or
|
||||
* |CallStack::kNone| if it is currently free (or freed).
|
||||
* mAcquired
|
||||
* Indicates if this resource is currently acquired.
|
||||
*/
|
||||
CallStack mAcquisitionContext;
|
||||
bool mAcquired;
|
||||
};
|
||||
|
||||
protected:
|
||||
@ -251,26 +250,25 @@ protected:
|
||||
} //NS_NEEDS_RESOURCE(this)
|
||||
|
||||
/**
|
||||
* GetAcquisitionContext
|
||||
* Return the calling context from which this resource was acquired,
|
||||
* or CallStack::kNone if it's currently free.
|
||||
* GetAcquisitionState
|
||||
* Return whether or not this resource was acquired.
|
||||
*
|
||||
* *NOT* thread safe. Requires ownership of underlying resource.
|
||||
*/
|
||||
CallStack GetAcquisitionContext()
|
||||
bool GetAcquisitionState()
|
||||
{
|
||||
return mDDEntry->mAcquisitionContext;
|
||||
return mDDEntry->mAcquired;
|
||||
}
|
||||
|
||||
/**
|
||||
* SetAcquisitionContext
|
||||
* Set the calling context from which this resource was acquired.
|
||||
* SetAcquisitionState
|
||||
* Set whether or not this resource was acquired.
|
||||
*
|
||||
* *NOT* thread safe. Requires ownership of underlying resource.
|
||||
*/
|
||||
void SetAcquisitionContext(CallStack aAcquisitionContext)
|
||||
void SetAcquisitionState(bool aAcquisitionState)
|
||||
{
|
||||
mDDEntry->mAcquisitionContext = aAcquisitionContext;
|
||||
mDDEntry->mAcquired = aAcquisitionState;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user