summaryrefslogtreecommitdiff
path: root/protocols/MRA/src/Mra_proto.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-12-01 19:26:23 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-12-01 19:26:23 +0000
commitc78567f150e79befc0ccf85b555802e58696ac30 (patch)
treee57fe72839e600b2cef907d694dd916aa3d29e7b /protocols/MRA/src/Mra_proto.cpp
parentc97a1472f85733e0cf4f3423af6647ff2fa00520 (diff)
- no need to wait for a thread inside OnPreShutdown;
- less crazy popup generation code git-svn-id: http://svn.miranda-ng.org/main/trunk@7024 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/MRA/src/Mra_proto.cpp')
-rw-r--r--protocols/MRA/src/Mra_proto.cpp46
1 files changed, 13 insertions, 33 deletions
diff --git a/protocols/MRA/src/Mra_proto.cpp b/protocols/MRA/src/Mra_proto.cpp
index abbbf9b687..554e284e0a 100644
--- a/protocols/MRA/src/Mra_proto.cpp
+++ b/protocols/MRA/src/Mra_proto.cpp
@@ -9,30 +9,21 @@ DWORD CMraProto::StartConnect()
return ERROR_OPERATION_ABORTED;
// поток ещё/уже не работал, поставили статус что работает и запускаем
- if (InterlockedCompareExchange((volatile LONG*)&m_dwThreadWorkerRunning, TRUE, FALSE) == FALSE) {
- CMStringA szEmail;
- mraGetStringA(NULL, "e-mail", szEmail);
+ if (InterlockedCompareExchange((volatile LONG*)&m_dwThreadWorkerRunning, TRUE, FALSE))
+ return 0;
- CMStringA szPass;
- if (szEmail.GetLength() > 5 && GetPassDB(szPass)) {
- InterlockedExchange((volatile LONG*)&m_dwThreadWorkerLastPingTime, GetTickCount());
- m_hThreadWorker = ForkThreadEx(&CMraProto::MraThreadProc, NULL, 0);
- if (m_hThreadWorker == NULL) {
- DWORD dwRetErrorCode = GetLastError();
- InterlockedExchange((volatile LONG*)&m_dwThreadWorkerRunning, FALSE);
- SetStatus(ID_STATUS_OFFLINE);
- return dwRetErrorCode;
- }
- }
- else {
- MraThreadClean();
- if (szEmail.GetLength() <= 5)
- MraPopupShowFromAgentW(MRA_POPUP_TYPE_WARNING, 0, TranslateT("Please, setup e-mail in options"));
- else
- MraPopupShowFromAgentW(MRA_POPUP_TYPE_WARNING, 0, TranslateT("Please, setup password in options"));
- }
- }
+ CMStringA szEmail;
+ mraGetStringA(NULL, "e-mail", szEmail);
+ CMStringA szPass;
+ if (szEmail.GetLength() <= 5)
+ MraPopupShowFromAgentW(MRA_POPUP_TYPE_WARNING, 0, TranslateT("Please, setup e-mail in options"));
+ else if (!GetPassDB(szPass))
+ MraPopupShowFromAgentW(MRA_POPUP_TYPE_WARNING, 0, TranslateT("Please, setup password in options"));
+ else {
+ InterlockedExchange((volatile LONG*)&m_dwThreadWorkerLastPingTime, GetTickCount());
+ ForkThreadEx(&CMraProto::MraThreadProc, NULL, 0);
+ }
return 0;
}
@@ -104,22 +95,11 @@ void CMraProto::MraThreadProc(LPVOID lpParameter)
}
}
- MraThreadClean();
-}
-
-void CMraProto::MraThreadClean()
-{
MraMPopSessionQueueFlush(hMPopSessionQueue);
Netlib_CloseHandle(m_hConnection);// called twice, if user set offline, its normal
m_hConnection = NULL;
dwCMDNum = 0;
- SleepEx(100, FALSE);// to prevent high CPU load by some status plugins like allwaysonline
-
- if (m_hThreadWorker) {
- CloseHandle(m_hThreadWorker);
- m_hThreadWorker = NULL;
- }
InterlockedExchange((volatile LONG*)&m_dwThreadWorkerRunning, FALSE);
SetStatus(ID_STATUS_OFFLINE);
}