Skip to content

Commit

Permalink
Fix two issues with the epoll code
Browse files Browse the repository at this point in the history
- epoll_wait expects the timeout value in milliseconds instead of microseconds
- set the EPOLLET flag for all events as a cheaper alternative of
removing the event handlers each time they are triggered
  • Loading branch information
smalltalking committed Dec 14, 2020
1 parent c93cd67 commit 3db3888
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions platforms/unix/vm/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ aioPoll(long microSeconds)
do {
const unsigned long long start = ioUTCMicroseconds();
const struct epoll_event events[128];
const int eventsTriggered = epoll_wait(epollFd, (struct epoll_event*)events, 128, (int)microSeconds);
const int eventsTriggered = epoll_wait(epollFd, (struct epoll_event*)events, 128, (int)(microSeconds / 1000));
if (eventsTriggered == -1) {
if (errno != EINTR) {
perror("epoll_wait");
Expand Down Expand Up @@ -715,7 +715,7 @@ aioHandle(int fd, aioHandler handlerFn, int mask)
if (mask & AIO_R) data->readHandler = handlerFn;
if (mask & AIO_W) data->writeHandler = handlerFn;
if (mask & AIO_X) data->exceptionHandler = handlerFn;
event->events = epollFlagsForAIOFlags[mask & AIO_RWX] | (mask & AIO_EXT ? EPOLLET : 0);
event->events = epollFlagsForAIOFlags[mask & AIO_RWX] | EPOLLET;
int epoll_operation = data->aioMask & AIO_RWX
? EPOLL_CTL_MOD
: EPOLL_CTL_ADD;
Expand Down

0 comments on commit 3db3888

Please sign in to comment.