Do not report spurious deadlocks caused by TRY_LOCK
This commit is contained in:
parent
908037fe16
commit
f342dac1cb
2 changed files with 7 additions and 7 deletions
|
@ -1141,7 +1141,7 @@ static void potential_deadlock_detected(const std::pair<void*, void*>& mismatch,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void push_lock(void* c, const CLockLocation& locklocation)
|
static void push_lock(void* c, const CLockLocation& locklocation, bool fTry)
|
||||||
{
|
{
|
||||||
bool fOrderOK = true;
|
bool fOrderOK = true;
|
||||||
if (lockstack.get() == NULL)
|
if (lockstack.get() == NULL)
|
||||||
|
@ -1152,7 +1152,7 @@ static void push_lock(void* c, const CLockLocation& locklocation)
|
||||||
|
|
||||||
(*lockstack).push_back(std::make_pair(c, locklocation));
|
(*lockstack).push_back(std::make_pair(c, locklocation));
|
||||||
|
|
||||||
BOOST_FOREACH(const PAIRTYPE(void*, CLockLocation)& i, (*lockstack))
|
if (!fTry) BOOST_FOREACH(const PAIRTYPE(void*, CLockLocation)& i, (*lockstack))
|
||||||
{
|
{
|
||||||
if (i.first == c) break;
|
if (i.first == c) break;
|
||||||
|
|
||||||
|
@ -1183,9 +1183,9 @@ static void pop_lock()
|
||||||
dd_mutex.unlock();
|
dd_mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs)
|
void EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs, bool fTry)
|
||||||
{
|
{
|
||||||
push_lock(cs, CLockLocation(pszName, pszFile, nLine));
|
push_lock(cs, CLockLocation(pszName, pszFile, nLine), fTry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LeaveCritical()
|
void LeaveCritical()
|
||||||
|
|
|
@ -190,10 +190,10 @@ typedef boost::interprocess::interprocess_recursive_mutex CCriticalSection;
|
||||||
typedef boost::interprocess::interprocess_mutex CWaitableCriticalSection;
|
typedef boost::interprocess::interprocess_mutex CWaitableCriticalSection;
|
||||||
|
|
||||||
#ifdef DEBUG_LOCKORDER
|
#ifdef DEBUG_LOCKORDER
|
||||||
void EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs);
|
void EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs, bool fTry = false);
|
||||||
void LeaveCritical();
|
void LeaveCritical();
|
||||||
#else
|
#else
|
||||||
void static inline EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs) {}
|
void static inline EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs, bool fTry = false) {}
|
||||||
void static inline LeaveCritical() {}
|
void static inline LeaveCritical() {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ public:
|
||||||
{
|
{
|
||||||
if (!lock.owns())
|
if (!lock.owns())
|
||||||
{
|
{
|
||||||
EnterCritical(pszName, pszFile, nLine, (void*)(lock.mutex()));
|
EnterCritical(pszName, pszFile, nLine, (void*)(lock.mutex()), true);
|
||||||
lock.try_lock();
|
lock.try_lock();
|
||||||
if (!lock.owns())
|
if (!lock.owns())
|
||||||
LeaveCritical();
|
LeaveCritical();
|
||||||
|
|
Loading…
Reference in a new issue