From fe7e3a6032bf680998da291616f39c679920f481 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Mon, 11 May 2015 11:32:39 +0000 Subject: minus critical section git-svn-id: http://svn.miranda-ng.org/main/trunk@13525 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Xfire/src/Xfire_avatar_loader.cpp | 9 +------- protocols/Xfire/src/Xfire_avatar_loader.h | 2 +- protocols/Xfire/src/Xfire_gamelist.cpp | 6 +----- protocols/Xfire/src/Xfire_gamelist.h | 2 +- protocols/Xfire/src/main.cpp | 33 ++++++++--------------------- 5 files changed, 13 insertions(+), 39 deletions(-) (limited to 'protocols/Xfire/src') diff --git a/protocols/Xfire/src/Xfire_avatar_loader.cpp b/protocols/Xfire/src/Xfire_avatar_loader.cpp index 4ace311827..92a84ef978 100644 --- a/protocols/Xfire/src/Xfire_avatar_loader.cpp +++ b/protocols/Xfire/src/Xfire_avatar_loader.cpp @@ -4,17 +4,11 @@ Xfire_avatar_loader::Xfire_avatar_loader(xfirelib::Client* client) { threadrunning = FALSE; this->client = client; - InitializeCriticalSection(&this->avatarMutex); } Xfire_avatar_loader::~Xfire_avatar_loader() { //liste leeren, damit der laufende thread abgebrochen wird list.clear(); - //warten bis der thread geschlossen wurde - EnterCriticalSection(&this->avatarMutex); - LeaveCriticalSection(&this->avatarMutex); - //critical section entfernen - DeleteCriticalSection(&this->avatarMutex); } void Xfire_avatar_loader::loadThread(void *arg) { @@ -24,7 +18,7 @@ void Xfire_avatar_loader::loadThread(void *arg) { if (!loader) return; - EnterCriticalSection(&loader->avatarMutex); + mir_cslock lck(loader->avatarMutex); loader->threadrunning = TRUE; while (1){ @@ -56,7 +50,6 @@ void Xfire_avatar_loader::loadThread(void *arg) { } loader->threadrunning = FALSE; - LeaveCriticalSection(&loader->avatarMutex); return; } diff --git a/protocols/Xfire/src/Xfire_avatar_loader.h b/protocols/Xfire/src/Xfire_avatar_loader.h index 3a7419f688..c906e26bf1 100644 --- a/protocols/Xfire/src/Xfire_avatar_loader.h +++ b/protocols/Xfire/src/Xfire_avatar_loader.h @@ -46,7 +46,7 @@ class Xfire_avatar_loader : public Xfire_base { private: static void loadThread(LPVOID lparam); xfirelib::Client *client; - CRITICAL_SECTION avatarMutex; + mir_cs avatarMutex; public: vector list; BOOL threadrunning; diff --git a/protocols/Xfire/src/Xfire_gamelist.cpp b/protocols/Xfire/src/Xfire_gamelist.cpp index 728c9c7bb9..4e98b8e381 100644 --- a/protocols/Xfire/src/Xfire_gamelist.cpp +++ b/protocols/Xfire/src/Xfire_gamelist.cpp @@ -52,7 +52,6 @@ Xfire_gamelist::Xfire_gamelist() { nextgameid = 0; ingame = FALSE; - InitializeCriticalSection(&gamlistMutex); } //dekonstruktor @@ -62,7 +61,6 @@ Xfire_gamelist::~Xfire_gamelist() { if (game) delete game; } gamelist.clear(); - DeleteCriticalSection(&gamlistMutex); } //hole das nächste game @@ -97,9 +95,7 @@ BOOL Xfire_gamelist::getnextGame(Xfire_game**currentgame) void Xfire_gamelist::Block(BOOL block) { if (block) - EnterCriticalSection(&gamlistMutex); - else - LeaveCriticalSection(&gamlistMutex); + mir_cslock lck(gamlistMutex); } //fügt simple ein gameobject in den vector ein diff --git a/protocols/Xfire/src/Xfire_gamelist.h b/protocols/Xfire/src/Xfire_gamelist.h index 3cdf8eb9a9..e6e86d93ee 100644 --- a/protocols/Xfire/src/Xfire_gamelist.h +++ b/protocols/Xfire/src/Xfire_gamelist.h @@ -44,7 +44,7 @@ private: HANDLE dummymenuitem; unsigned int nextgameid; BOOL ingame; - CRITICAL_SECTION gamlistMutex; + mir_cs gamlistMutex; void removeDummyMenuItem(); void createDummyMenuItem(); diff --git a/protocols/Xfire/src/main.cpp b/protocols/Xfire/src/main.cpp index 1fa30287c6..14f8e7200a 100644 --- a/protocols/Xfire/src/main.cpp +++ b/protocols/Xfire/src/main.cpp @@ -108,9 +108,9 @@ ULONG_PTR gdiplusToken; xfire_prefitem xfireconfig[XFIRE_RECVPREFSPACKET_MAXCONFIGS]; extern xfireconfigitem xfireconfigitems[XFIRE_RECVPREFSPACKET_SUPPORTEDONFIGS]; -CRITICAL_SECTION modeMsgsMutex; -CRITICAL_SECTION avatarMutex; -CRITICAL_SECTION connectingMutex; +mir_cs modeMsgsMutex; +mir_cs avatarMutex; +mir_cs connectingMutex; DWORD pid = NULL; //processid des gefunden spiels DWORD ts2pid = NULL; // processid vom teamspeak/ventrilo @@ -768,10 +768,6 @@ extern "C" __declspec(dllexport) int Unload(void) pthread_win32_process_detach_np (); #endif - DeleteCriticalSection(&modeMsgsMutex); - DeleteCriticalSection(&connectingMutex); - DeleteCriticalSection(&avatarMutex); - Gdiplus::GdiplusShutdown(gdiplusToken); return 0; @@ -802,7 +798,7 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID lpvReserved) //suche nach ini und danach starte gamedetection thread void StartIniUpdateAndDetection(LPVOID dummy) { - EnterCriticalSection(&connectingMutex); + mir_cslock lck(connectingMutex); //ini/ico updater, nur wenn aktiv if (db_get_b(NULL, protocolname, "autoiniupdate", 0)) @@ -816,8 +812,6 @@ void StartIniUpdateAndDetection(LPVOID dummy) #else mir_forkthread(inigamedetectiont, NULL); #endif - - LeaveCriticalSection(&connectingMutex); } INT_PTR UrlCall(WPARAM wparam, LPARAM lparam) { @@ -1028,10 +1022,6 @@ extern "C" __declspec(dllexport) int Load(void) { mir_getLP(&pluginInfo); - InitializeCriticalSection(&modeMsgsMutex); - InitializeCriticalSection(&connectingMutex); - InitializeCriticalSection(&avatarMutex); - Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); //keine protoversion in der db, dann wohl der erste start von xfire @@ -1434,13 +1424,13 @@ static void ConnectingThread(LPVOID params) { WPARAM wParam = (WPARAM)params; - EnterCriticalSection(&connectingMutex); + mir_cslock lck(connectingMutex); if (myClient != NULL&&myClient->client != NULL) myClient->run(); else { - EnterCriticalSection(&connectingMutex); + mir_cslock lck(connectingMutex); return; } @@ -1459,8 +1449,6 @@ static void ConnectingThread(LPVOID params) bpStatus = wParam; ProtoBroadcastAck(protocolname, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, wParam); - - LeaveCriticalSection(&connectingMutex); } //======================================================= @@ -1769,10 +1757,7 @@ void SetAvatar2(void *arg) { } void SetAvatar(void *arg) -//void SetAvatar(MCONTACT hContact, char* username) { - //EnterCriticalSection(&avatarMutex); - //WaitForSingleObject(hMutex, INFINITE); static int lasttime = 0; int sleep = db_get_w(NULL, protocolname, "avatarloadlatency", 250); @@ -3135,8 +3120,9 @@ void CreateGroup(char*grpn, char*field) { } -INT_PTR SetAwayMsg(WPARAM wParam, LPARAM lParam) { - EnterCriticalSection(&modeMsgsMutex); +INT_PTR SetAwayMsg(WPARAM wParam, LPARAM lParam) +{ + mir_cslock lck(modeMsgsMutex); if ((char*)lParam == NULL) { if (wParam == ID_STATUS_ONLINE) @@ -3174,7 +3160,6 @@ INT_PTR SetAwayMsg(WPARAM wParam, LPARAM lParam) { myClient->Status(statusmessage[1]); } } - LeaveCriticalSection(&modeMsgsMutex); return 0; } -- cgit v1.2.3