| 58 | # if defined(ACL_HAS_POLL) |
| 59 | |
| 60 | static int check(ACL_SOCKET listener, ACL_SOCKET client, ACL_SOCKET result[2]) |
| 61 | { |
| 62 | int ret; |
| 63 | struct pollfd fds[2]; |
| 64 | |
| 65 | while (result[0] == ACL_SOCKET_INVALID || result[1] ==ACL_SOCKET_INVALID) { |
| 66 | int i = 0; |
| 67 | if (result[1] == ACL_SOCKET_INVALID) { |
| 68 | fds[i].fd = listener; |
| 69 | fds[i].events = POLLIN; |
| 70 | fds[i].revents = 0; |
| 71 | i++; |
| 72 | } |
| 73 | |
| 74 | if (result[0] == ACL_SOCKET_INVALID) { |
| 75 | fds[i].fd = client; |
| 76 | fds[i].events = POLLOUT; |
| 77 | fds[i].revents = 0; |
| 78 | } |
| 79 | |
| 80 | ret = WSAPoll(fds, 2, 10000); |
| 81 | if (ret < 0) { |
| 82 | if (acl_last_error() == ACL_EINTR) { |
| 83 | continue; |
| 84 | } |
| 85 | acl_msg_error("WSAPoll error: %s", acl_last_serror()); |
| 86 | return -1; |
| 87 | } else if (ret == 0) { |
| 88 | acl_msg_error("WSAPoll timeout: %s", acl_last_serror()); |
| 89 | return -1; |
| 90 | } |
| 91 | |
| 92 | if ((fds[0].revents & POLLIN)) { |
| 93 | result[1] = accept(listener, NULL, 0); |
| 94 | } |
| 95 | if ((fds[1].revents & POLLOUT)) { |
| 96 | result[0] = client; |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | return 0; |
| 101 | } |
| 102 | |
| 103 | # else |
| 104 |
no test coverage detected
searching dependent graphs…