Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from May 3, 2023

Conversation

niemyjski
Copy link
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
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
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
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
7 checks passed
@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.

None yet

2 participants