From 0703b6bd61870c6375ace8d1ac12fc3d8e8751c9 Mon Sep 17 00:00:00 2001 From: Jason Yeo Date: Tue, 30 Apr 2019 19:24:20 +0800 Subject: [PATCH] (#17) Remove slashes from mutex name These will be replaced with underscores. Mutex names must not contain a slash, since it's the namespace separator. There was a similar issue in NLog: https://github.com/NLog/NLog/issues/1882 Where a similar change was made: https://github.com/NLog/NLog/pull/1930/files --- src/Core/Configuration/Settings.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Core/Configuration/Settings.cs b/src/Core/Configuration/Settings.cs index 0ed71a34..4bdea4f9 100644 --- a/src/Core/Configuration/Settings.cs +++ b/src/Core/Configuration/Settings.cs @@ -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 @@ -841,4 +846,4 @@ private void ExecuteSynchronized(Action ioOperation) } } -} \ No newline at end of file +}