Wait for milliseconds until the given file descriptor becomes * writable/readable/exception */
| 467 | /* Wait for milliseconds until the given file descriptor becomes |
| 468 | * writable/readable/exception */ |
| 469 | int aeWait(int fd, int mask, long long milliseconds) { |
| 470 | struct pollfd pfd; |
| 471 | int retmask = 0, retval; |
| 472 | |
| 473 | memset(&pfd, 0, sizeof(pfd)); |
| 474 | pfd.fd = fd; |
| 475 | if (mask & AE_READABLE) pfd.events |= POLLIN; |
| 476 | if (mask & AE_WRITABLE) pfd.events |= POLLOUT; |
| 477 | |
| 478 | if ((retval = poll(&pfd, 1, milliseconds))== 1) { |
| 479 | if (pfd.revents & POLLIN) retmask |= AE_READABLE; |
| 480 | if (pfd.revents & POLLOUT) retmask |= AE_WRITABLE; |
| 481 | if (pfd.revents & POLLERR) retmask |= AE_WRITABLE; |
| 482 | if (pfd.revents & POLLHUP) retmask |= AE_WRITABLE; |
| 483 | return retmask; |
| 484 | } else { |
| 485 | return retval; |
| 486 | } |
| 487 | } |
| 488 | |
| 489 | void aeMain(aeEventLoop *eventLoop) { |
| 490 | aeProcessEvents(eventLoop, AE_ALL_EVENTS| |
no test coverage detected