mirror of
https://github.com/vale981/ray
synced 2025-03-09 12:56:46 -04:00
49 lines
1.7 KiB
Diff
49 lines
1.7 KiB
Diff
diff --git cpp/src/plasma/thirdparty/ae/ae.c cpp/src/plasma/thirdparty/ae/ae.c
|
|
index dfb722444..96d9e537a 100644
|
|
--- cpp/src/plasma/thirdparty/ae/ae.c
|
|
+++ cpp/src/plasma/thirdparty/ae/ae.c
|
|
@@ -428,19 +428,33 @@ int aeProcessEvents(aeEventLoop *eventLoop, int flags)
|
|
/* Wait for milliseconds until the given file descriptor becomes
|
|
* writable/readable/exception */
|
|
int aeWait(int fd, int mask, long long milliseconds) {
|
|
- struct pollfd pfd;
|
|
+ short revents = 0;
|
|
+ struct timeval tv = { milliseconds / 1000, (milliseconds % 1000) * 1000 };
|
|
int retmask = 0, retval;
|
|
|
|
- memset(&pfd, 0, sizeof(pfd));
|
|
- pfd.fd = fd;
|
|
- if (mask & AE_READABLE) pfd.events |= POLLIN;
|
|
- if (mask & AE_WRITABLE) pfd.events |= POLLOUT;
|
|
+ fd_set rset, wset;
|
|
+ FD_ZERO(&rset);
|
|
+ FD_ZERO(&wset);
|
|
+ if (mask & AE_READABLE) {
|
|
+ FD_SET(fd, &rset);
|
|
+ } else if (mask & AE_WRITABLE) {
|
|
+ FD_SET(fd, &wset);
|
|
+ }
|
|
+
|
|
+ if ((retval = select(fd + 1, &rset, &wset, NULL, &tv)) > 0) {
|
|
+ if (FD_ISSET(fd, &rset)) {
|
|
+ revents |= POLLIN;
|
|
+ }
|
|
+ if (FD_ISSET(fd, &wset)) {
|
|
+ revents |= POLLOUT;
|
|
+ }
|
|
+ }
|
|
|
|
- if ((retval = poll(&pfd, 1, milliseconds))== 1) {
|
|
- if (pfd.revents & POLLIN) retmask |= AE_READABLE;
|
|
- if (pfd.revents & POLLOUT) retmask |= AE_WRITABLE;
|
|
- if (pfd.revents & POLLERR) retmask |= AE_WRITABLE;
|
|
- if (pfd.revents & POLLHUP) retmask |= AE_WRITABLE;
|
|
+ if (retval== 1) {
|
|
+ if (revents & POLLIN) retmask |= AE_READABLE;
|
|
+ if (revents & POLLOUT) retmask |= AE_WRITABLE;
|
|
+ if (revents & POLLERR) retmask |= AE_WRITABLE;
|
|
+ if (revents & POLLHUP) retmask |= AE_WRITABLE;
|
|
return retmask;
|
|
} else {
|
|
return retval;
|
|
--
|