From: Timo Sirainen Date: Wed, 26 Jan 2011 19:47:52 +0000 (+0200) Subject: ioloop: Use -1 for infinite poll/epoll timeout rather than INT_MAX. X-Git-Tag: 2.1.alpha1~402 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=61cb43e243a82d4037e919ec996fcb840c669e9c;p=thirdparty%2Fdovecot%2Fcore.git ioloop: Use -1 for infinite poll/epoll timeout rather than INT_MAX. Should improve performance a tiny bit and also works around a CPU eater bug in Linux 2.6.37. --- diff --git a/src/lib/ioloop.c b/src/lib/ioloop.c index 5d393a3d5e..9ce1f44820 100644 --- a/src/lib/ioloop.c +++ b/src/lib/ioloop.c @@ -252,11 +252,12 @@ int io_loop_get_wait_time(struct ioloop *ioloop, struct timeval *tv_r) item = priorityq_peek(ioloop->timeouts); timeout = (struct timeout *)item; if (timeout == NULL) { - /* no timeouts. give it INT_MAX msecs. */ + /* no timeouts. use INT_MAX msecs for timeval and + return -1 for poll/epoll infinity. */ tv_r->tv_sec = INT_MAX / 1000; tv_r->tv_usec = 0; ioloop->next_max_time = (1ULL << (TIME_T_MAX_BITS-1)) - 1; - return INT_MAX; + return -1; } tv_now.tv_sec = 0;