X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=win%2Finspircd_win32wrapper.cpp;h=d82c90a61be9d6a99f380e507d01e03e25afdc99;hb=82a3069c5604a8b815021532ebfcc98cb50c9c7d;hp=bc68a24863e9ea5f78c9b7ec6cf10d1da0f62895;hpb=bf269e3cc7c10ec7b93d1edad37d6c82fbf98585;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/win/inspircd_win32wrapper.cpp b/win/inspircd_win32wrapper.cpp index bc68a2486..d82c90a61 100644 --- a/win/inspircd_win32wrapper.cpp +++ b/win/inspircd_win32wrapper.cpp @@ -549,14 +549,14 @@ void FindDNS(std::string& server) ServerInstance->Logs->Log("CONFIG",DEFAULT," set to '%s' as first active resolver in registry.", nameserver.c_str()); } -int gettimeofday(struct timeval * tv, void * tz) +int clock_gettime(int clock, struct timespec * tv) { if(tv == NULL) return -1; DWORD mstime = timeGetTime(); tv->tv_sec = time(NULL); - tv->tv_usec = (mstime - (tv->tv_sec * 1000)) * 1000; + tv->tv_usec = (mstime - (tv->tv_sec * 1000)) * 1000000; return 0; } @@ -652,6 +652,7 @@ int getcpu() while (pEnumerator) { VARIANT vtProp; + VariantInit(&vtProp); /* Next item */ HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn); @@ -664,9 +665,10 @@ int getcpu() if (!FAILED(hr)) { /* Matches our process ID? */ - if (vtProp.uintVal == GetCurrentProcessId()) - { - VariantClear(&vtProp); + UINT pid = vtProp.uintVal; + VariantClear(&vtProp); + if (pid == GetCurrentProcessId()) + { /* Get CPU percentage for this process */ hr = pclsObj->Get(L"PercentProcessorTime", 0, &vtProp, 0, 0); if (!FAILED(hr)) @@ -674,18 +676,19 @@ int getcpu() /* Deal with wide string ickyness. Who in their right * mind puts a number in a bstrVal wide string item?! */ - VariantClear(&vtProp); cpu = 0; std::wstringstream out(vtProp.bstrVal); out >> cpu; - break; + VariantClear(&vtProp); } + pclsObj->Release(); + break; } + pclsObj->Release(); } } pEnumerator->Release(); - pclsObj->Release(); } SysFreeString(Language);