Index: src/plugin/PluginMutex.cpp |
=================================================================== |
--- a/src/plugin/PluginMutex.cpp |
+++ b/src/plugin/PluginMutex.cpp |
@@ -5,29 +5,28 @@ |
#include "sddl.h" |
-CPluginMutex::CPluginMutex(const CString& name, int errorSubidBase) : m_isLocked(false), m_errorSubidBase(errorSubidBase), m_name(name) |
+CPluginMutex::CPluginMutex(const std::wstring & name, int errorSubidBase) |
+ : m_isLocked(false), m_errorSubidBase(errorSubidBase), mutex_name( L"Global\\AdblockPlus" + name ) |
{ |
if (m_errorSubidBase != PLUGIN_ERROR_MUTEX_DEBUG_FILE) |
{ |
- DEBUG_MUTEX("Mutex::Create name:" + name) |
+ DEBUG_MUTEX( "Mutex::Create name:" + mutex_name ) |
} |
- |
- m_hMutex = ::CreateMutex(NULL, FALSE, "Global\\AdblockPlus" + name); |
- |
+ m_hMutex = ::CreateMutexW( NULL, FALSE, mutex_name.c_str() ); |
if (m_hMutex == NULL) |
{ |
DWORD error = GetLastError(); |
- m_hMutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, "Global\\AdblockPlus" + name); |
+ m_hMutex = OpenMutexW( MUTEX_ALL_ACCESS, FALSE, mutex_name.c_str() ); |
if (m_hMutex == NULL) |
{ |
- m_hMutex = ::CreateMutex(NULL, FALSE, "Local\\AdblockPlus" + name); |
+ m_hMutex = ::CreateMutexW( NULL, FALSE, mutex_name.c_str() ); |
Oleksandr
2014/06/26 00:48:43
We should try to open a mutex in Local namespace i
Eric
2014/06/26 15:13:56
This a defect I introduced. I don't think I notice
|
if (m_hMutex == NULL) |
{ |
- m_hMutex = OpenMutex(NULL, FALSE, "Local\\AdblockPlus" + name); |
+ m_hMutex = OpenMutexW( NULL, FALSE, mutex_name.c_str() ); |
if (m_hMutex == NULL) |
{ |
DWORD error = GetLastError(); |
- DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_MUTEX, PLUGIN_ERROR_MUTEX_CREATE + m_errorSubidBase, "Mutex::CreateMutex"); |
+ DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_MUTEX, PLUGIN_ERROR_MUTEX_CREATE + m_errorSubidBase, L"Mutex::CreateMutex"); |
} |
} |
else |
@@ -40,12 +39,12 @@ |
break; |
case WAIT_TIMEOUT: |
- DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_MUTEX, PLUGIN_ERROR_MUTEX_WAIT_TIMEOUT + m_errorSubidBase, "Mutex::CreateMutex - Timeout"); |
+ DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_MUTEX, PLUGIN_ERROR_MUTEX_WAIT_TIMEOUT + m_errorSubidBase, L"Mutex::CreateMutex - Timeout"); |
m_hMutex = NULL; |
break; |
case WAIT_FAILED: |
- DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_MUTEX, PLUGIN_ERROR_MUTEX_WAIT + m_errorSubidBase, "Mutex::CreateMutex - Wait error"); |
+ DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_MUTEX, PLUGIN_ERROR_MUTEX_WAIT + m_errorSubidBase, L"Mutex::CreateMutex - Wait error"); |
break; |
} |
} |
@@ -62,12 +61,12 @@ |
break; |
case WAIT_TIMEOUT: |
- DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_MUTEX, PLUGIN_ERROR_MUTEX_WAIT_TIMEOUT + m_errorSubidBase, "Mutex::CreateMutex - Timeout"); |
+ DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_MUTEX, PLUGIN_ERROR_MUTEX_WAIT_TIMEOUT + m_errorSubidBase, L"Mutex::CreateMutex - Timeout"); |
m_hMutex = NULL; |
break; |
case WAIT_FAILED: |
- DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_MUTEX, PLUGIN_ERROR_MUTEX_WAIT + m_errorSubidBase, "Mutex::CreateMutex - Wait error"); |
+ DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_MUTEX, PLUGIN_ERROR_MUTEX_WAIT + m_errorSubidBase, L"Mutex::CreateMutex - Wait error"); |
break; |
} |
} |
@@ -77,7 +76,7 @@ |
{ |
if (m_errorSubidBase != PLUGIN_ERROR_MUTEX_DEBUG_FILE) |
{ |
- DEBUG_MUTEX("Mutex::Release name:" + m_name) |
+ DEBUG_MUTEX("Mutex::Release name:" + mutex_name) |
} |
if (m_isLocked) |
@@ -89,7 +88,7 @@ |
{ |
if (!::ReleaseMutex(m_hMutex)) |
{ |
- DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_MUTEX, PLUGIN_ERROR_MUTEX_RELEASE + m_errorSubidBase, "Mutex::ReleaseMutex"); |
+ DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_MUTEX, PLUGIN_ERROR_MUTEX_RELEASE + m_errorSubidBase, L"Mutex::ReleaseMutex"); |
} |
} |