mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
Removed the global lock
This commit is contained in:
parent
283be5d22f
commit
c4aa053de9
2 changed files with 1 additions and 39 deletions
|
@ -158,7 +158,7 @@ namespace Ombi.Core.Authentication
|
|||
if (!email.Equals(result.User?.Email))
|
||||
{
|
||||
user.Email = result.User?.Email;
|
||||
await GlobalMutex.Lock(async () => await UpdateAsync(user));
|
||||
await UpdateAsync(user);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace Ombi.Helpers
|
||||
{
|
||||
public static class GlobalMutex
|
||||
{
|
||||
public static T Lock<T>(Func<T> func)
|
||||
{
|
||||
const string mutexId = "Global\\OMBI";
|
||||
|
||||
using (var mutex = new Mutex(false, mutexId, out var __))
|
||||
{
|
||||
var hasHandle = false;
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
hasHandle = mutex.WaitOne(5000, false);
|
||||
if (hasHandle == false)
|
||||
throw new TimeoutException("Timeout waiting for exclusive access");
|
||||
}
|
||||
catch (AbandonedMutexException)
|
||||
{
|
||||
hasHandle = true;
|
||||
}
|
||||
|
||||
return func();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (hasHandle)
|
||||
mutex.ReleaseMutex();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue