Skip to content

Commit

Permalink
[core] Set CLOEXEC for epoll on Linux
Browse files Browse the repository at this point in the history
epoll_create1() was added to the kernel in version 2.6.27. Library
support is provided in glibc starting with version 2.9 which was
released at the year of 2008.
  • Loading branch information
quink-black authored and maxsharabayko committed Jul 22, 2021
1 parent 1df29db commit a34aa08
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion srtcore/epoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ int CEPoll::create(CEPollDesc** pout)
int localid = 0;

#ifdef LINUX
localid = epoll_create(1024);
int flags = 0;
#if ENABLE_SOCK_CLOEXEC
flags |= EPOLL_CLOEXEC;
#endif
localid = epoll_create1(flags);
/* Possible reasons of -1 error:
EMFILE: The per-user limit on the number of epoll instances imposed by /proc/sys/fs/epoll/max_user_instances was encountered.
ENFILE: The system limit on the total number of open files has been reached.
Expand Down

0 comments on commit a34aa08

Please sign in to comment.