From 3b620119f530681ddffcdfdcabd8a41e426a9e7f Mon Sep 17 00:00:00 2001 From: Rozhuk Ivan Date: Wed, 5 Mar 2014 16:52:43 +0000 Subject: MRA: fix SetStatus() on ForkThreadEx() fail. git-svn-id: http://svn.miranda-ng.org/main/trunk@8414 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/MRA/src/Mra_proto.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'protocols/MRA/src') diff --git a/protocols/MRA/src/Mra_proto.cpp b/protocols/MRA/src/Mra_proto.cpp index 4fdcebcf40..321c314025 100644 --- a/protocols/MRA/src/Mra_proto.cpp +++ b/protocols/MRA/src/Mra_proto.cpp @@ -8,6 +8,10 @@ DWORD CMraProto::StartConnect() if (!g_dwGlobalPluginRunning) return ERROR_OPERATION_ABORTED; + // поток ещё/уже не работал, поставили статус что работает и запускаем + if (InterlockedCompareExchange((volatile LONG*)&m_dwThreadWorkerRunning, TRUE, FALSE)) + return 0; + CMStringA szEmail; mraGetStringA(NULL, "e-mail", szEmail); @@ -17,13 +21,12 @@ DWORD CMraProto::StartConnect() else if (!GetPassDB(szPass)) MraPopupShowFromAgentW(MRA_POPUP_TYPE_WARNING, 0, TranslateT("Please, setup password in options")); else { - // поток ещё/уже не работал, поставили статус что работает и запускаем - if (InterlockedCompareExchange((volatile LONG*)&m_dwThreadWorkerRunning, TRUE, FALSE)) - return 0; InterlockedExchange((volatile LONG*)&m_dwThreadWorkerLastPingTime, GetTickCount()); - ForkThreadEx(&CMraProto::MraThreadProc, NULL, 0); + if (INVALID_HANDLE_VALUE == ForkThreadEx(&CMraProto::MraThreadProc, NULL, 0)) /* Thread create fail. */ + MraPopupShowFromAgentW(MRA_POPUP_TYPE_ERROR, 0, TranslateT("Thread create fail")); return 0; } + InterlockedExchange((volatile LONG*)&m_dwThreadWorkerRunning, FALSE); return ERROR_OPERATION_ABORTED; } -- cgit v1.2.3