Changed the lock in BasicResults from a regular object lock to a semaphore in order to be able to lock asynchronously

This commit is contained in:
Carl Johnsen
2025-05-22 08:19:56 +02:00
parent 28fcff68ba
commit 2b5dfbbb15
+7 -2
View File
@@ -181,7 +181,7 @@ namespace Duplicati.Library.Main
protected readonly BasicResults m_parent;
protected System.Threading.Thread m_callerThread;
protected readonly object m_lock = new object();
protected readonly SemaphoreSlim m_lock = new(1, 1);
protected readonly Queue<DbMessage> m_dbqueue;
public virtual ParsedResultType ParsedResult
@@ -266,7 +266,8 @@ namespace Duplicati.Library.Main
await m_parent.FlushLog(db);
else
{
lock (m_lock)
await m_lock.WaitAsync();
try
{
while (m_dbqueue.Count > 0)
{
@@ -274,6 +275,10 @@ namespace Duplicati.Library.Main
await db.LogMessage(el.Type, el.Message, el.Exception);
}
}
finally
{
m_lock.Release();
}
}
}