MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / aeApiAssociate

Function aeApiAssociate

src/ae_evport.c:126–153  ·  view source on GitHub ↗

* Helper function to invoke port_associate for the given fd and mask. */

Source from the content-addressed store, hash-verified

124 * Helper function to invoke port_associate for the given fd and mask.
125 */
126static 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
155static int aeApiAddEvent(aeEventLoop *eventLoop, int fd, int mask) {
156 aeApiState *state = eventLoop->apidata;

Callers 3

aeApiAddEventFunction · 0.85
aeApiDelEventFunction · 0.85
aeApiPollFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected