Skip to content

Commit

Permalink
Merge pull request #18 from jsyeo/jsyeo-mutex-name
Browse files Browse the repository at this point in the history
(#17) Replace slashes with underscores in the mutex's name
  • Loading branch information
gep13 authored Oct 14, 2021
2 parents 4c6bbc9 + 0703b6b commit f471409
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Core/Configuration/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,13 @@ private void ExecuteSynchronized(Action ioOperation)
{
var fileName = _fileSystem.GetFullPath(_fileName);

// Global: ensure mutex is honored across TS sessions
using (var mutex = new Mutex(false, "Global\\" + EncryptionUtility.GenerateUniqueToken(fileName)))
// Mutex names must not contain a slash, it's the namespace separator
var uniqueToken = EncryptionUtility.GenerateUniqueToken(fileName);
uniqueToken = uniqueToken.Replace('\\', '_');
uniqueToken = uniqueToken.Replace('/', '_');

// Global: ensure mutex is honored across TS sessions
using (var mutex = new Mutex(false, "Global\\" + uniqueToken))
{
var owner = false;
try
Expand All @@ -841,4 +846,4 @@ private void ExecuteSynchronized(Action ioOperation)

}
}
}
}

0 comments on commit f471409

Please sign in to comment.