* Helper function to invoke port_associate for the given fd and mask. */
| 124 | * Helper function to invoke port_associate for the given fd and mask. |
| 125 | */ |
| 126 | static int aeApiAssociate(const char *where, int portfd, int fd, int mask) { |
| 127 | int events = 0; |
| 128 | int rv, err; |
| 129 | |
| 130 | if (mask & AE_READABLE) |
| 131 | events |= POLLIN; |
| 132 | if (mask & AE_WRITABLE) |
| 133 | events |= POLLOUT; |
| 134 | |
| 135 | if (evport_debug) |
| 136 | fprintf(stderr, "%s: port_associate(%d, 0x%x) = ", where, fd, events); |
| 137 | |
| 138 | rv = port_associate(portfd, PORT_SOURCE_FD, fd, events, |
| 139 | (void *)(uintptr_t)mask); |
| 140 | err = errno; |
| 141 | |
| 142 | if (evport_debug) |
| 143 | fprintf(stderr, "%d (%s)\n", rv, rv == 0 ? "no error" : strerror(err)); |
| 144 | |
| 145 | if (rv == -1) { |
| 146 | fprintf(stderr, "%s: port_associate: %s\n", where, strerror(err)); |
| 147 | |
| 148 | if (err == EAGAIN) |
| 149 | fprintf(stderr, "aeApiAssociate: event port limit exceeded."); |
| 150 | } |
| 151 | |
| 152 | return rv; |
| 153 | } |
| 154 | |
| 155 | static int aeApiAddEvent(aeEventLoop *eventLoop, int fd, int mask) { |
| 156 | aeApiState *state = eventLoop->apidata; |
no outgoing calls
no test coverage detected