From cf45ff050dad2570c3172e111d739a3ae11a9ec1 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Thu, 30 Apr 2015 06:34:32 +0000 Subject: minus critical section git-svn-id: http://svn.miranda-ng.org/main/trunk@13277 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/SecureIM/src/commonheaders.cpp | 2 +- plugins/SecureIM/src/commonheaders.h | 2 +- plugins/SecureIM/src/crypt_lists.cpp | 3 +-- plugins/SecureIM/src/crypt_misc.cpp | 9 +++------ plugins/SecureIM/src/main.cpp | 2 -- 5 files changed, 6 insertions(+), 12 deletions(-) (limited to 'plugins/SecureIM/src') diff --git a/plugins/SecureIM/src/commonheaders.cpp b/plugins/SecureIM/src/commonheaders.cpp index 28e8dc4e52..260cac63e1 100644 --- a/plugins/SecureIM/src/commonheaders.cpp +++ b/plugins/SecureIM/src/commonheaders.cpp @@ -21,7 +21,7 @@ BOOL bGPGloaded = false, bGPGkeyrings = false, bSavePass = false; BOOL bSFT, bSOM, bASI, bMCD, bSCM, bDGP, bAIP, bNOL, bAAK, bMCM; BYTE bPGP, bGPG; DWORD iCoreVersion = 0; -CRITICAL_SECTION localQueueMutex; +mir_cs localQueueMutex; LPSTR myDBGetStringDecode(MCONTACT hContact, const char *szModule, const char *szSetting) { diff --git a/plugins/SecureIM/src/commonheaders.h b/plugins/SecureIM/src/commonheaders.h index 7d5d182983..22ac92ebc3 100644 --- a/plugins/SecureIM/src/commonheaders.h +++ b/plugins/SecureIM/src/commonheaders.h @@ -83,7 +83,7 @@ extern BOOL bGPGloaded, bGPGkeyrings, bSavePass; extern BOOL bSFT, bSOM, bASI, bMCD, bSCM, bDGP, bAIP, bNOL, bAAK, bMCM; extern BYTE bPGP, bGPG; extern DWORD iCoreVersion; -extern CRITICAL_SECTION localQueueMutex; +extern mir_cs localQueueMutex; __forceinline int SendBroadcast(MCONTACT hContact, int type, int result, HANDLE hProcess, LPARAM lParam) { diff --git a/plugins/SecureIM/src/crypt_lists.cpp b/plugins/SecureIM/src/crypt_lists.cpp index e15f612b35..c4914de114 100644 --- a/plugins/SecureIM/src/crypt_lists.cpp +++ b/plugins/SecureIM/src/crypt_lists.cpp @@ -167,7 +167,7 @@ void addMsg2Queue(pUinKey ptr, WPARAM wParam, LPSTR szMsg) pWM ptrMessage; - EnterCriticalSection(&localQueueMutex); + mir_cslock lck(localQueueMutex); if (ptr->msgQueue == NULL) { // create new @@ -195,7 +195,6 @@ void addMsg2Queue(pUinKey ptr, WPARAM wParam, LPSTR szMsg) } else ptrMessage->Message = mir_strdup(szMsg); - LeaveCriticalSection(&localQueueMutex); } void getContactNameA(MCONTACT hContact, LPSTR szName) diff --git a/plugins/SecureIM/src/crypt_misc.cpp b/plugins/SecureIM/src/crypt_misc.cpp index 4c51d678cf..b43c516716 100644 --- a/plugins/SecureIM/src/crypt_misc.cpp +++ b/plugins/SecureIM/src/crypt_misc.cpp @@ -18,7 +18,7 @@ static void sttWaitForExchange(LPVOID param) // if keyexchange failed or timeout if (ptr->waitForExchange == 1 || ptr->waitForExchange == 3) { // протухло - отправляем незашифрованно, если надо if (ptr->msgQueue && msgbox1(0, sim104, MODULENAME, MB_YESNO | MB_ICONQUESTION) == IDYES) { - EnterCriticalSection(&localQueueMutex); + mir_cslock lck(localQueueMutex); ptr->sendQueue = true; pWM ptrMessage = ptr->msgQueue; while (ptrMessage) { @@ -33,13 +33,12 @@ static void sttWaitForExchange(LPVOID param) } ptr->msgQueue = NULL; ptr->sendQueue = false; - LeaveCriticalSection(&localQueueMutex); } ptr->waitForExchange = 0; ShowStatusIconNotify(ptr->hContact); } else if (ptr->waitForExchange == 2) { // дослать очередь через установленное соединение - EnterCriticalSection(&localQueueMutex); + mir_cslock lck(localQueueMutex); // we need to resend last send back message with new crypto Key pWM ptrMessage = ptr->msgQueue; while (ptrMessage) { @@ -54,10 +53,9 @@ static void sttWaitForExchange(LPVOID param) } ptr->msgQueue = NULL; ptr->waitForExchange = 0; - LeaveCriticalSection(&localQueueMutex); } else if (ptr->waitForExchange == 0) { // очистить очередь - EnterCriticalSection(&localQueueMutex); + mir_cslock lck(localQueueMutex); // we need to resend last send back message with new crypto Key pWM ptrMessage = ptr->msgQueue; while (ptrMessage) { @@ -67,7 +65,6 @@ static void sttWaitForExchange(LPVOID param) mir_free(tmp); } ptr->msgQueue = NULL; - LeaveCriticalSection(&localQueueMutex); } } diff --git a/plugins/SecureIM/src/main.cpp b/plugins/SecureIM/src/main.cpp index 8abf787e46..a70e7c6611 100644 --- a/plugins/SecureIM/src/main.cpp +++ b/plugins/SecureIM/src/main.cpp @@ -308,7 +308,6 @@ extern "C" __declspec(dllexport) int __cdecl Load(void) mir_getLP(&pluginInfoEx); DisableThreadLibraryCalls(g_hInst); - InitializeCriticalSection(&localQueueMutex); char temp[MAX_PATH]; GetTempPath(sizeof(temp), temp); @@ -389,7 +388,6 @@ extern "C" __declspec(dllexport) int __cdecl Load(void) extern "C" __declspec(dllexport) int __cdecl Unload() { - DeleteCriticalSection(&localQueueMutex); freelib(); return 0; } -- cgit v1.2.3