diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2015-04-30 06:23:49 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2015-04-30 06:23:49 +0000 |
commit | 5023d486be9fc4f61473f899b48ae97b6126ce40 (patch) | |
tree | 4dbfd81905bc925d340a08337ca035a372f4afaf /plugins/StatusPlugins | |
parent | 2926b727b08fafd10e2429dac0efc21505b850e3 (diff) |
minus critical section
git-svn-id: http://svn.miranda-ng.org/main/trunk@13274 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/StatusPlugins')
-rw-r--r-- | plugins/StatusPlugins/KeepStatus/keepstatus.cpp | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/plugins/StatusPlugins/KeepStatus/keepstatus.cpp b/plugins/StatusPlugins/KeepStatus/keepstatus.cpp index bb4ff2f96c..10f36e80da 100644 --- a/plugins/StatusPlugins/KeepStatus/keepstatus.cpp +++ b/plugins/StatusPlugins/KeepStatus/keepstatus.cpp @@ -28,7 +28,7 @@ struct TimerInfo { HANDLE hEvent; }; -static CRITICAL_SECTION GenTimerCS, GenStatusCS, CheckContinueslyCS; +static mir_cs GenTimerCS, GenStatusCS, CheckContinueslyCS; static HANDLE hProtoAckHook = NULL; static HANDLE hStatusChangeHook = NULL; @@ -171,16 +171,14 @@ static void GetCurrentConnectionSettings() static PROTOCOLSETTINGEX** GetCurrentProtoSettingsCopy() { - EnterCriticalSection(&GenStatusCS); + mir_cslock lck(GenStatusCS); PROTOCOLSETTINGEX **ps = (PROTOCOLSETTINGEX**)malloc(connectionSettings.getCount()*sizeof(PROTOCOLSETTINGEX *)); if (ps == NULL) { - LeaveCriticalSection(&GenStatusCS); return NULL; } for (int i = 0; i < connectionSettings.getCount(); i++) { ps[i] = (PROTOCOLSETTINGEX*)calloc(1, sizeof(PROTOCOLSETTINGEX)); if (ps[i] == NULL) { - LeaveCriticalSection(&GenStatusCS); return NULL; } @@ -192,7 +190,6 @@ static PROTOCOLSETTINGEX** GetCurrentProtoSettingsCopy() ps[i]->szName = cs.szName; ps[i]->tszAccName = cs.tszAccName; } - LeaveCriticalSection(&GenStatusCS); return ps; } @@ -212,7 +209,7 @@ static int AssignStatus(TConnectionSettings* cs, int status, int lastStatus, TCH if (status < MIN_STATUS || status > MAX_STATUS) return -1; - EnterCriticalSection(&GenStatusCS); + mir_cslock lck(GenStatusCS); char dbSetting[128]; mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s_enabled", cs->szName); @@ -238,7 +235,6 @@ static int AssignStatus(TConnectionSettings* cs, int status, int lastStatus, TCH cs->szMsg = NULL; } - LeaveCriticalSection(&GenStatusCS); return 0; } @@ -346,7 +342,7 @@ static int StartTimerFunction(int timer, int timeout, BOOL restart) { int res = 0; - EnterCriticalSection(&GenTimerCS); + mir_cslock lck(GenTimerCS); log_debugA("StartTimer: %d, %d, %d", timer, timeout, restart); log_debugA("ack: %u, chk: %u, aft: %u, cnt: %u, con: %u", processAckTimerId, checkConnectionTimerId, afterCheckTimerId, checkContinTimerId, checkConnectingTimerId); if (timer & IDT_PROCESSACK) { @@ -422,7 +418,6 @@ static int StartTimerFunction(int timer, int timeout, BOOL restart) log_debugA("ack: %u, chk: %u, aft: %u, cnt: %u, con: %u", processAckTimerId, checkConnectionTimerId, afterCheckTimerId, checkContinTimerId, checkConnectingTimerId); log_debugA("StartTimer done %d", res); - LeaveCriticalSection(&GenTimerCS); return res; } @@ -457,7 +452,7 @@ static int StopTimer(int timer) { int res = 0; - EnterCriticalSection(&GenTimerCS); + mir_cslock lck(GenTimerCS); log_debugA("StopTimer %d", timer); log_debugA("ack: %u, chk: %u, aft: %u, cnt: %u, con: %u", processAckTimerId, checkConnectionTimerId, afterCheckTimerId, checkContinTimerId, checkConnectingTimerId); @@ -513,7 +508,6 @@ static int StopTimer(int timer) log_debugA("ack: %u, chk: %u, aft: %u, cnt: %u, con: %u", processAckTimerId, checkConnectionTimerId, afterCheckTimerId, checkContinTimerId, checkConnectingTimerId); log_debugA("StopTimer done %d", res); - LeaveCriticalSection(&GenTimerCS); return res; } @@ -759,7 +753,7 @@ static void CheckContinueslyFunction(void *) static int pingFailures = 0; // one at the time is enough, do it the 'easy' way - EnterCriticalSection(&CheckContinueslyCS); + mir_cslock lck(CheckContinueslyCS); // do a ping, even if reconnecting bool doPing = false; @@ -780,7 +774,6 @@ static void CheckContinueslyFunction(void *) if (!doPing) { log_debugA("CheckContinueslyFunction: All protocols should be offline, no need to check connection"); - LeaveCriticalSection(&CheckContinueslyCS); return; } @@ -835,7 +828,6 @@ static void CheckContinueslyFunction(void *) } if (StartTimer(IDT_CHECKCONN, -1, FALSE)) { - LeaveCriticalSection(&CheckContinueslyCS); return; // already connecting, leave } @@ -861,7 +853,6 @@ static void CheckContinueslyFunction(void *) } if (StartTimer(IDT_CHECKCONN | IDT_PROCESSACK, -1, FALSE)) {// are our 'set offlines' noticed? log_debugA("CheckContinueslyFunction: currently checking"); - LeaveCriticalSection(&CheckContinueslyCS); return; } log_infoA("KeepStatus: connection lost! (continuesly check)"); @@ -872,7 +863,6 @@ static void CheckContinueslyFunction(void *) maxRetries = -1; StartTimer(IDT_CHECKCONN, initDelay, FALSE); } - LeaveCriticalSection(&CheckContinueslyCS); } static VOID CALLBACK CheckContinueslyTimer(HWND, UINT, UINT_PTR, DWORD) @@ -1199,18 +1189,11 @@ static int onShutdown(WPARAM, LPARAM) connectionSettings.destroy(); - DeleteCriticalSection(&GenTimerCS); - DeleteCriticalSection(&GenStatusCS); - DeleteCriticalSection(&CheckContinueslyCS); return 0; } int CSModuleLoaded(WPARAM, LPARAM) { - InitializeCriticalSection(&GenTimerCS); - InitializeCriticalSection(&GenStatusCS); - InitializeCriticalSection(&CheckContinueslyCS); - protoList = (OBJLIST<PROTOCOLSETTINGEX>*)&connectionSettings; hMessageWindow = NULL; |