From: Gunnar Beutner Date: Thu, 19 Apr 2012 07:41:12 +0000 (+0200) Subject: Bugfix: Make sure timeval is valid. X-Git-Tag: v0.0.1~619 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fd64dc5a9952ecd1d4de5a7c8d871580f084f8c1;p=icinga2 Bugfix: Make sure timeval is valid. --- diff --git a/base/application.cpp b/base/application.cpp index 16dba4575..f7ba08925 100644 --- a/base/application.cpp +++ b/base/application.cpp @@ -79,13 +79,15 @@ void Application::RunEventLoop(void) nfds = fd; } - long sleep = (long)(Timer::GetNextCall() - time(NULL)); + time_t now = time(NULL); + time_t next = Timer::GetNextCall(); + long sleep = (next < now) ? 0 : (next - now); if (m_ShuttingDown) break; timeval tv; - tv.tv_sec = sleep; + tv.tv_sec = (sleep < 0) ? 0 : sleep; tv.tv_usec = 0; int ready;