From 2a7dd5e67d621a2079b6bbbe47b3a4b6bba8a42b Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 6 Apr 2003 15:43:41 +0200 Subject: Avoiding high CPU load in case the connection to LIRC gets lost --- tools.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'tools.c') diff --git a/tools.c b/tools.c index ff462ba8..21ec526c 100644 --- a/tools.c +++ b/tools.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: tools.c 1.76 2002/11/24 20:17:31 kls Exp $ + * $Id: tools.c 1.77 2003/04/06 15:31:45 kls Exp $ */ #include "tools.h" @@ -620,11 +620,13 @@ bool cFile::FileReady(int FileDes, int TimeoutMs) struct timeval timeout; FD_ZERO(&set); FD_SET(FileDes, &set); - if (TimeoutMs < 100) - TimeoutMs = 100; - timeout.tv_sec = TimeoutMs / 1000; - timeout.tv_usec = (TimeoutMs % 1000) * 1000; - return select(FD_SETSIZE, &set, NULL, NULL, &timeout) > 0 && FD_ISSET(FileDes, &set); + if (TimeoutMs >= 0) { + if (TimeoutMs < 100) + TimeoutMs = 100; + timeout.tv_sec = TimeoutMs / 1000; + timeout.tv_usec = (TimeoutMs % 1000) * 1000; + } + return select(FD_SETSIZE, &set, NULL, NULL, (TimeoutMs >= 0) ? &timeout : NULL) > 0 && FD_ISSET(FileDes, &set); } bool cFile::FileReadyForWriting(int FileDes, int TimeoutMs) -- cgit v1.2.3