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

Function aeApiAddEvent

src/ae_evport.c:155–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153}
154
155static int aeApiAddEvent(aeEventLoop *eventLoop, int fd, int mask) {
156 aeApiState *state = eventLoop->apidata;
157 int fullmask, pfd;
158
159 if (evport_debug)
160 fprintf(stderr, "aeApiAddEvent: fd %d mask 0x%x\n", fd, mask);
161
162 /*
163 * Since port_associate's "events" argument replaces any existing events, we
164 * must be sure to include whatever events are already associated when
165 * we call port_associate() again.
166 */
167 fullmask = mask | eventLoop->events[fd].mask;
168 pfd = aeApiLookupPending(state, fd);
169
170 if (pfd != -1) {
171 /*
172 * This fd was recently returned from aeApiPoll. It should be safe to
173 * assume that the consumer has processed that poll event, but we play
174 * it safer by simply updating pending_mask. The fd will be
175 * re-associated as usual when aeApiPoll is called again.
176 */
177 if (evport_debug)
178 fprintf(stderr, "aeApiAddEvent: adding to pending fd %d\n", fd);
179 state->pending_masks[pfd] |= fullmask;
180 return 0;
181 }
182
183 return (aeApiAssociate("aeApiAddEvent", state->portfd, fd, fullmask));
184}
185
186static void aeApiDelEvent(aeEventLoop *eventLoop, int fd, int mask) {
187 aeApiState *state = eventLoop->apidata;

Callers

nothing calls this directly

Calls 2

aeApiLookupPendingFunction · 0.85
aeApiAssociateFunction · 0.85

Tested by

no test coverage detected