MCPcopy Create free account
hub / github.com/F-Stack/f-stack / aeApiAddEvent

Function aeApiAddEvent

app/redis-6.2.6/src/ae_epoll.c:74–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74static int aeApiAddEvent(aeEventLoop *eventLoop, int fd, int mask) {
75 aeApiState *state = eventLoop->apidata;
76 struct epoll_event ee = {0}; /* avoid valgrind warning */
77 /* If the fd was already monitored for some event, we need a MOD
78 * operation. Otherwise we need an ADD operation. */
79 int op = eventLoop->events[fd].mask == AE_NONE ?
80 EPOLL_CTL_ADD : EPOLL_CTL_MOD;
81
82 ee.events = 0;
83 mask |= eventLoop->events[fd].mask; /* Merge old events */
84 if (mask & AE_READABLE) ee.events |= EPOLLIN;
85 if (mask & AE_WRITABLE) ee.events |= EPOLLOUT;
86 ee.data.fd = fd;
87 if (epoll_ctl(state->epfd,op,fd,&ee) == -1) return -1;
88 return 0;
89}
90
91static void aeApiDelEvent(aeEventLoop *eventLoop, int fd, int delmask) {
92 aeApiState *state = eventLoop->apidata;

Callers 1

aeCreateFileEventFunction · 0.70

Calls 1

epoll_ctlFunction · 0.85

Tested by

no test coverage detected