Fix: access to _AcInstanceLocks was not threadsafe
This commit is contained in:
1 parent
0bcc7779b8
commit
d17fe4b039
1 file changed
+11
-5
@@ -192,17 +192,23 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
private static readonly Object _Lock = new Object();
|
private static readonly Object _Lock = new Object();
|
||||||
|
private static readonly Object _DictionaryLock = new Object();
|
||||||
private static readonly Dictionary<Int64, object> _AcInstanceLocks = new Dictionary<Int64, object>(20);
|
private static readonly Dictionary<Int64, object> _AcInstanceLocks = new Dictionary<Int64, object>(20);
|
||||||
|
|
||||||
private static object _GetLockToken(IntPtr pAcDecoder)
|
private static object _GetLockToken(IntPtr pAcDecoder)
|
||||||
{
|
{
|
||||||
object l = null;
|
object l;
|
||||||
_AcInstanceLocks.TryGetValue(pAcDecoder.ToInt64(), out l);
|
|
||||||
if (l == null)
|
lock (_DictionaryLock)
|
||||||
{
|
{
|
||||||
l = new object();
|
_AcInstanceLocks.TryGetValue(pAcDecoder.ToInt64(), out l);
|
||||||
_AcInstanceLocks.Add(pAcDecoder.ToInt64(), l);
|
if (l == null)
|
||||||
|
{
|
||||||
|
l = new object();
|
||||||
|
_AcInstanceLocks.Add(pAcDecoder.ToInt64(), l);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user