iepoll might wait too long
Kenji Kazumura
kzr at jp.fujitsu.com
Wed Mar 30 13:24:22 UTC 2016
Hello,
When I looked into "EPollArrayWrapper.c" I found the code to be fixed.
At line 56, the 4th parameter of epoll_wait is 'timeout',
but I think it should be 'remaining' as 'ipoll' of 'PollArrayWrapper.c' does.
EPollArrayWrapper.c
44 static int
45 iepoll(int epfd, struct epoll_event *events, int numfds, jlong timeout)
46 {
47 jlong start, now;
48 int remaining = timeout;
49 struct timeval t;
50 int diff;
51
52 gettimeofday(&t, NULL);
53 start = t.tv_sec * 1000 + t.tv_usec / 1000;
54
55 for (;;) {
56 int res = epoll_wait(epfd, events, numfds, timeout);
57 if (res < 0 && errno == EINTR) {
58 if (remaining >= 0) {
59 gettimeofday(&t, NULL);
60 now = t.tv_sec * 1000 + t.tv_usec / 1000;
61 diff = now - start;
62 remaining -= diff;
63 if (diff < 0 || remaining <= 0) {
64 return 0;
65 }
66 start = now;
67 }
68 } else {
69 return res;
70 }
71 }
72 }
-Kenji Kazumura
More information about the nio-dev
mailing list