Skip to content

Lock conflicts occur when multiple sites (with ExceptionLess.net) are deployed on a server#305

Merged
niemyjski merged 1 commit intomainfrom
feature/locking-improvements
May 3, 2023
Merged

Lock conflicts occur when multiple sites (with ExceptionLess.net) are deployed on a server#305
niemyjski merged 1 commit intomainfrom
feature/locking-improvements

Conversation

@niemyjski
Copy link
Copy Markdown
Member

@niemyjski niemyjski commented May 3, 2023

Addresses #257

@niemyjski niemyjski added the bug label May 3, 2023
@niemyjski niemyjski requested a review from ejsmith May 3, 2023 13:20
@niemyjski niemyjski self-assigned this May 3, 2023
Comment on lines +272 to +275
if (_flushMutex != null) {
_flushMutex.Close();
_flushMutex = null;
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this, I don't see how it can hurt.

Comment on lines +315 to +333
#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));
}

System.Diagnostics.Trace.WriteLine("Exceptionless: Error creating global mutex: {0}", ex.ToString());
throw;
}
#else
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Global mutexes are not supported on .NET Core or mono. There probably is a case we don't fully cover here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the docs they are when the mutex name starts with Global\ which you are doing.

@niemyjski niemyjski merged commit 31a3653 into main May 3, 2023
@niemyjski niemyjski deleted the feature/locking-improvements branch May 3, 2023 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants