1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-11-28 09:07:19 +03:00

Limit event handler timeout to 2 seconds

This commit is contained in:
Maxime Coste 2014-12-03 19:55:53 +00:00
parent 51b88bef10
commit a51dd737ea

View File

@ -87,7 +87,8 @@ void EventManager::handle_next_events(EventMode mode)
auto timeout = duration_cast<microseconds>(next_timer - Clock::now()).count(); auto timeout = duration_cast<microseconds>(next_timer - Clock::now()).count();
constexpr auto us = 1000000; 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); int res = select(max_fd + 1, &rfds, nullptr, nullptr, &tv);
// copy forced fds *after* poll, so that signal handlers can write to // copy forced fds *after* poll, so that signal handlers can write to