From 40cdcc55a06345508cd7c0c95acefe582db8a0fd Mon Sep 17 00:00:00 2001 From: Ezequiel Lovelle Date: Tue, 29 Jan 2019 23:06:00 -0300 Subject: [PATCH] Use up-to-date system call to create epoll context epoll_create() is a deprecated, older variant of epoll_create1(). Older versions of epoll_create() used to take a size argument to provide a hint about the number of file descriptors to be watched. Nowadays the kernel dynamically sizes the required data structures. --- src/ae_epoll.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ae_epoll.c b/src/ae_epoll.c index 410aac70d..39becdf70 100644 --- a/src/ae_epoll.c +++ b/src/ae_epoll.c @@ -45,7 +45,13 @@ static int aeApiCreate(aeEventLoop *eventLoop) { zfree(state); return -1; } - state->epfd = epoll_create(1024); /* 1024 is just a hint for the kernel */ +#ifdef EPOLL_CLOEXEC + state->epfd = epoll_create1(EPOLL_CLOEXEC); +#else + /* Create the kernel epoll using the old interface. + * Since Linux 2.6.8, the size argument is ignored */ + state->epfd = epoll_create(1024); +#endif if (state->epfd == -1) { zfree(state->events); zfree(state);