aboutsummaryrefslogtreecommitdiffstats
path: root/iolooper-select.c
diff options
context:
space:
mode:
Diffstat (limited to 'iolooper-select.c')
-rw-r--r--iolooper-select.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/iolooper-select.c b/iolooper-select.c
index bf7ae8f..f5aecbd 100644
--- a/iolooper-select.c
+++ b/iolooper-select.c
@@ -146,17 +146,26 @@ iolooper_wait( IoLooper* iol, int64_t duration )
int count = iolooper_fd_count(iol);
int ret;
fd_set errs;
+ struct timeval tm0, *tm = NULL;
if (count == 0)
return 0;
+ if (duration < 0)
+ tm = NULL;
+ else {
+ tm = &tm0;
+ tm->tv_sec = duration / 1000;
+ tm->tv_usec = (duration - 1000*tm->tv_sec) * 1000;
+ }
+
FD_ZERO(&errs);
do {
iol->reads_result[0] = iol->reads[0];
iol->writes_result[0] = iol->writes[0];
- ret = select( count, iol->reads_result, iol->writes_result, &errs, NULL);
+ ret = select( count, iol->reads_result, iol->writes_result, &errs, tm);
} while (ret < 0 && errno == EINTR);
return ret;