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

Function aeApiCreate

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

Source from the content-addressed store, hash-verified

37} aeApiState;
38
39static int aeApiCreate(aeEventLoop *eventLoop) {
40 aeApiState *state = zmalloc(sizeof(aeApiState));
41
42 if (!state) return -1;
43 state->events = zmalloc(sizeof(struct epoll_event)*eventLoop->setsize);
44 if (!state->events) {
45 zfree(state);
46 return -1;
47 }
48 state->epfd = epoll_create(1024); /* 1024 is just a hint for the kernel */
49 if (state->epfd == -1) {
50 zfree(state->events);
51 zfree(state);
52 return -1;
53 }
54 anetCloexec(state->epfd);
55 eventLoop->apidata = state;
56 return 0;
57}
58
59static int aeApiResize(aeEventLoop *eventLoop, int setsize) {
60 aeApiState *state = eventLoop->apidata;

Callers 1

aeCreateEventLoopFunction · 0.70

Calls 4

zmallocFunction · 0.85
epoll_createFunction · 0.85
anetCloexecFunction · 0.85
zfreeFunction · 0.70

Tested by

no test coverage detected