| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
| 2 | 2 |
| 3 #include "PluginMutex.h" | 3 #include "PluginMutex.h" |
| 4 #include "PluginClient.h" | 4 #include "PluginClient.h" |
| 5 #include "sddl.h" | 5 #include "sddl.h" |
| 6 | 6 |
| 7 | 7 |
| 8 CPluginMutex::CPluginMutex(const std::wstring & name, int errorSubidBase) | 8 CPluginMutex::CPluginMutex(const std::wstring & name, int errorSubidBase) |
| 9 : m_isLocked(false), m_errorSubidBase(errorSubidBase), mutex_name( L"Global\\A dblockPlus" + name ) | 9 : m_isLocked(false), m_errorSubidBase(errorSubidBase), mutex_name( L"Global\\A dblockPlus" + name ) |
| 10 { | 10 { |
| 11 if (m_errorSubidBase != PLUGIN_ERROR_MUTEX_DEBUG_FILE) | 11 if (m_errorSubidBase != PLUGIN_ERROR_MUTEX_DEBUG_FILE) |
| 12 { | 12 { |
| 13 DEBUG_MUTEX( "Mutex::Create name:" + mutex_name ) | 13 DEBUG_MUTEX( "Mutex::Create name:" + mutex_name ) |
| 14 } | 14 } |
| 15 m_hMutex = ::CreateMutexW( NULL, FALSE, mutex_name.c_str() ); | 15 m_hMutex = ::CreateMutexW( NULL, FALSE, mutex_name.c_str() ); |
| 16 if (m_hMutex == NULL) | 16 if (m_hMutex == NULL) |
| 17 { | 17 { |
| 18 DWORD error = GetLastError(); | 18 DWORD error = GetLastError(); |
| 19 m_hMutex = OpenMutexW( MUTEX_ALL_ACCESS, FALSE, mutex_name.c_str() ); | 19 m_hMutex = OpenMutexW( MUTEX_ALL_ACCESS, FALSE, mutex_name.c_str() ); |
| 20 if (m_hMutex == NULL) | 20 if (m_hMutex == NULL) |
| 21 { | 21 { |
| 22 mutex_name = L"Local\\AdblockPlus" + name; | |
| 22 m_hMutex = ::CreateMutexW( NULL, FALSE, mutex_name.c_str() ); | 23 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
| |
| 23 if (m_hMutex == NULL) | 24 if (m_hMutex == NULL) |
| 24 { | 25 { |
| 25 m_hMutex = OpenMutexW( NULL, FALSE, mutex_name.c_str() ); | 26 m_hMutex = OpenMutexW( NULL, FALSE, mutex_name.c_str() ); |
| 26 if (m_hMutex == NULL) | 27 if (m_hMutex == NULL) |
| 27 { | 28 { |
| 28 DWORD error = GetLastError(); | 29 DWORD error = GetLastError(); |
| 29 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_MUTEX, PLUGIN_ERROR_MUT EX_CREATE + m_errorSubidBase, L"Mutex::CreateMutex"); | 30 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_MUTEX, PLUGIN_ERROR_MUT EX_CREATE + m_errorSubidBase, L"Mutex::CreateMutex"); |
| 30 } | 31 } |
| 31 } | 32 } |
| 32 else | 33 else |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 } | 93 } |
| 93 } | 94 } |
| 94 | 95 |
| 95 m_hMutex = NULL; | 96 m_hMutex = NULL; |
| 96 } | 97 } |
| 97 | 98 |
| 98 bool CPluginMutex::IsLocked() const | 99 bool CPluginMutex::IsLocked() const |
| 99 { | 100 { |
| 100 return m_isLocked; | 101 return m_isLocked; |
| 101 } | 102 } |
| LEFT | RIGHT |