From 5df94ff719eccd04c7450df35fb5e3f2b36e2ee7 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 13 Jul 2014 10:50:59 +0000 Subject: wrapping the most evident critical sections into a class git-svn-id: http://svn.miranda-ng.org/main/trunk@9785 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/IRCG/src/services.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'protocols/IRCG/src/services.cpp') diff --git a/protocols/IRCG/src/services.cpp b/protocols/IRCG/src/services.cpp index 02e7fdbc0d..ae0ecb7267 100644 --- a/protocols/IRCG/src/services.cpp +++ b/protocols/IRCG/src/services.cpp @@ -499,7 +499,7 @@ int __cdecl CIrcProto::GCEventHook(WPARAM wParam, LPARAM lParam) GCHOOK *gch = (GCHOOK*)lParam; CMString S = _T(""); - EnterCriticalSection(&m_gchook); + mir_cslock lock(m_gchook); // handle the hook if (gch) { @@ -769,7 +769,6 @@ int __cdecl CIrcProto::GCEventHook(WPARAM wParam, LPARAM lParam) } } - LeaveCriticalSection(&m_gchook); return 0; } @@ -906,7 +905,7 @@ int __cdecl CIrcProto::GCMenuHook(WPARAM, LPARAM lParam) int __cdecl CIrcProto::OnPreShutdown(WPARAM, LPARAM) { - EnterCriticalSection(&cs); + mir_cslock lock(cs); if (m_perform && IsConnected()) if (DoPerform("Event: Disconnect")) @@ -922,8 +921,6 @@ int __cdecl CIrcProto::OnPreShutdown(WPARAM, LPARAM) m_nickDlg->Close(); if (m_joinDlg) m_joinDlg->Close(); - - LeaveCriticalSection(&cs); return 0; } @@ -1011,9 +1008,10 @@ void __cdecl CIrcProto::ConnectServerThread(void*) nickflag = true; ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)Temp, ID_STATUS_CONNECTING); Sleep(100); - EnterCriticalSection(&cs); - Connect(si); - LeaveCriticalSection(&cs); + { + mir_cslock lock(cs); + Connect(si); + } if (IsConnected()) { if (m_mySpecifiedHost[0]) ForkThread(&CIrcProto::ResolveIPThread, new IPRESOLVE(m_mySpecifiedHost, IP_MANUAL)); -- cgit v1.2.3