From a51dd737ea4ed11159f3332defb9d54656ff9784 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 3 Dec 2014 19:55:53 +0000 Subject: [PATCH] Limit event handler timeout to 2 seconds --- src/event_manager.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/event_manager.cc b/src/event_manager.cc index 2c77e144..b7100a8f 100644 --- a/src/event_manager.cc +++ b/src/event_manager.cc @@ -87,7 +87,8 @@ void EventManager::handle_next_events(EventMode mode) auto timeout = duration_cast(next_timer - Clock::now()).count(); constexpr auto us = 1000000; - timeval tv{ (time_t)(timeout / us), (suseconds_t)(timeout % us) }; + // max timeout of 2 secs + timeval tv{ (time_t)(timeout > us ? 1 : 0), (suseconds_t)(timeout % us) }; int res = select(max_fd + 1, &rfds, nullptr, nullptr, &tv); // copy forced fds *after* poll, so that signal handlers can write to