]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - win/inspircd_win32wrapper.cpp
Remove incorrect access checks from m_ojoin
[user/henk/code/inspircd.git] / win / inspircd_win32wrapper.cpp
index bc68a24863e9ea5f78c9b7ec6cf10d1da0f62895..d82c90a61be9d6a99f380e507d01e03e25afdc99 100644 (file)
@@ -549,14 +549,14 @@ void FindDNS(std::string& server)
        ServerInstance->Logs->Log("CONFIG",DEFAULT,"<dns:server> 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);