diff --git a/lib/base/application.cpp b/lib/base/application.cpp index 51458dda3..5a423b804 100644 --- a/lib/base/application.cpp +++ b/lib/base/application.cpp @@ -138,7 +138,7 @@ void Application::TimeWatchThreadProc(void) double lastLoop = Utility::GetTime(); for (;;) { - Sleep(5000); + Utility::Sleep(5); double now = Utility::GetTime(); double timeDiff = lastLoop - now; diff --git a/lib/base/process.cpp b/lib/base/process.cpp index 0686d0c79..63c24117e 100644 --- a/lib/base/process.cpp +++ b/lib/base/process.cpp @@ -81,7 +81,7 @@ void Process::WorkerThreadProc(void) tv.tv_usec = 0; select(nfds + 1, &readfds, NULL, NULL, &tv); #else /* _MSC_VER */ - Sleep(1000); + Utility::Sleep(1); #endif /* _MSC_VER */ for (it = tasks.begin(); it != tasks.end(); ) { diff --git a/lib/base/unix.cpp b/lib/base/unix.cpp index 8997e814e..010c390a0 100644 --- a/lib/base/unix.cpp +++ b/lib/base/unix.cpp @@ -20,20 +20,9 @@ #include "i2-base.h" #ifndef _WIN32 -#include using namespace icinga; -/** - * Sleeps for the specified amount of time. - * - * @param milliseconds The amount of time in milliseconds. - */ -void Sleep(unsigned long milliseconds) -{ - usleep(milliseconds * 1000); -} - /** * Closes a socket. * diff --git a/lib/base/unix.h b/lib/base/unix.h index 31e5ae9c0..bc1f59e32 100644 --- a/lib/base/unix.h +++ b/lib/base/unix.h @@ -37,8 +37,6 @@ #include #include -void Sleep(unsigned long milliseconds); - typedef int SOCKET; #define INVALID_SOCKET (-1) void closesocket(SOCKET fd); diff --git a/lib/base/utility.cpp b/lib/base/utility.cpp index b6c89282d..f3fe5fbf1 100644 --- a/lib/base/utility.cpp +++ b/lib/base/utility.cpp @@ -309,3 +309,18 @@ pid_t Utility::GetPid(void) return GetCurrentProcessId(); #endif /* _WIN32 */ } + +/** + * Sleeps for the specified amount of time. + * + * @param timeout The timeout in seconds. + */ +void Utility::Sleep(double timeout) +{ +#ifndef _WIN32 + usleep(timeout * 1000 * 1000); +#else /* _WIN32 */ + Sleep(timeout * 1000); +#endif /* _WIN32 */ +} + diff --git a/lib/base/utility.h b/lib/base/utility.h index 96c914a37..b1f5d00ea 100644 --- a/lib/base/utility.h +++ b/lib/base/utility.h @@ -50,6 +50,8 @@ public: static pid_t GetPid(void); + static void Sleep(double timeout); + private: static bool m_SSLInitialized;