mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-12 03:57:32 +00:00
fix: Deadlock detection works better for false positives
This commit is contained in:
parent
6f5deaf1ea
commit
07ee6ce586
1 changed files with 16 additions and 2 deletions
|
|
@ -1,4 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
|
using ICD.Common.Utils.Services;
|
||||||
|
using ICD.Common.Utils.Services.Logging;
|
||||||
#if SIMPLSHARP
|
#if SIMPLSHARP
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
|
|
||||||
|
|
@ -44,8 +46,20 @@ namespace ICD.Common.Utils
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if (!m_CriticalSection.WaitForMutex(TIMEOUT))
|
int attempt = 1;
|
||||||
throw new InvalidProgramException("Deadlock detected in program");
|
while (!m_CriticalSection.WaitForMutex(TIMEOUT))
|
||||||
|
{
|
||||||
|
// Poor-man's stack trace
|
||||||
|
try
|
||||||
|
{
|
||||||
|
throw new InvalidProgramException("Failed to aquire mutex in expected timeframe - Attempt " + attempt++);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
ServiceProvider.GetService<ILoggerService>()
|
||||||
|
.AddEntry(eSeverity.Error, e, "Deadlock detected in program");
|
||||||
|
}
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
m_CriticalSection.Enter();
|
m_CriticalSection.Enter();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue