Skip to content

Commit

Permalink
Fixed mutex name
Browse files Browse the repository at this point in the history
  • Loading branch information
niemyjski committed May 3, 2023
1 parent 31a3653 commit eab5003
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Exceptionless/Logging/FileExceptionlessLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,27 +312,27 @@ protected string GetLastLinesFromFile(int lines = 100) {
/// Allows file based locking across processes
/// </summary>
private Mutex CreateSystemFileMutex(string fileNameOrPath) {
string name = GetFileBasedMutexName(fileNameOrPath);

#if NET45
var security = new MutexSecurity();
var allowEveryoneRule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl, AccessControlType.Allow);
security.AddAccessRule(allowEveryoneRule);

string name = GetFileBasedMutexName(fileNameOrPath);

try {
return new Mutex(false, name, out bool _, security);
} catch (Exception ex) {
if (ex is SecurityException || ex is UnauthorizedAccessException || ex is NotSupportedException || ex is NotImplementedException) {
System.Diagnostics.Trace.WriteLine("Exceptionless: Error creating global mutex falling back to previous implementation: {0}", ex.ToString());
return new Mutex(false, nameof(FileExceptionlessLog));
return new Mutex(false, name);
}

System.Diagnostics.Trace.WriteLine("Exceptionless: Error creating global mutex: {0}", ex.ToString());
throw;
}
#else
System.Diagnostics.Trace.WriteLine("Exceptionless: This platform does not support taking out a global mutex");
return new Mutex(false, nameof(FileExceptionlessLog));
return new Mutex(false, name);
#endif
}

Expand Down

0 comments on commit eab5003

Please sign in to comment.