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

Added better mutex support for .NET Core (SharedMode) #1998

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 4 additions & 11 deletions LiteDB/Client/Shared/SharedEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Threading;
#if NETFRAMEWORK
using System.Security.AccessControl;
using System.Security.Principal;
#endif
using System.Threading;


namespace LiteDB
{
Expand All @@ -27,17 +24,13 @@ public SharedEngine(EngineSettings settings)

try
{
#if NETFRAMEWORK
var allowEveryoneRule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null),
MutexRights.FullControl, AccessControlType.Allow);

var securitySettings = new MutexSecurity();
securitySettings.AddAccessRule(allowEveryoneRule);

_mutex = new Mutex(false, "Global\\" + name + ".Mutex", out _, securitySettings);
#else
_mutex = new Mutex(false, "Global\\" + name + ".Mutex");
#endif
_mutex = new Mutex(false, "Global\\" + name + ".Mutex", out _);
_mutex.SetAccessControl(securitySettings);
}
catch (NotSupportedException ex)
{
Expand Down
13 changes: 9 additions & 4 deletions LiteDB/LiteDB.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net45;netstandard1.3;netstandard2.0</TargetFrameworks>
<AssemblyVersion>5.0.10</AssemblyVersion>
<FileVersion>5.0.10</FileVersion>
<VersionPrefix>5.0.10</VersionPrefix>
<TargetFrameworks>net461;netstandard1.3;netstandard2.0</TargetFrameworks>
<AssemblyVersion>5.0.11</AssemblyVersion>
<FileVersion>5.0.11</FileVersion>
<VersionPrefix>5.0.11</VersionPrefix>
<Authors>Maurício David</Authors>
<Product>LiteDB</Product>
<Description>LiteDB - A lightweight embedded .NET NoSQL document store in a single datafile</Description>
Expand Down Expand Up @@ -65,6 +65,11 @@
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.5.1" />
<PackageReference Include="System.Security.Cryptography.Algorithms" Version="4.3.1" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.7.0" />
<PackageReference Include="System.Threading.AccessControl" Version="5.0.0" />
</ItemGroup>

<!-- End References -->

Expand Down