diff options
author | Kim Alvefur <zash@zash.se> | 2018-10-11 18:52:12 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2018-10-11 18:52:12 +0200 |
commit | ea072c9adba2359d834a85563a7d57479fd454de (patch) | |
tree | d2cc461481dd787e9d9726e7d6b70cb299d1c0c2 /util-src/poll.c | |
parent | dc9800c9296e02c5cad7eaaa76f8fc14ec3aa1f0 (diff) | |
download | prosody-ea072c9adba2359d834a85563a7d57479fd454de.tar.gz prosody-ea072c9adba2359d834a85563a7d57479fd454de.zip |
util.poll: Handle failed epoll FD creation
Diffstat (limited to 'util-src/poll.c')
-rw-r--r-- | util-src/poll.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/util-src/poll.c b/util-src/poll.c index 293c8c2b..d2d9dc03 100644 --- a/util-src/poll.c +++ b/util-src/poll.c @@ -386,8 +386,19 @@ int Lnew(lua_State *L) { /* Initialize state */ #ifdef USE_EPOLL - state->epoll_fd = epoll_create1(0); + state->epoll_fd = -1; state->processed = 0; + + int epoll_fd = epoll_create1(EPOLL_CLOEXEC); + + if(epoll_fd <= 0) { + lua_pushnil(L); + lua_pushstring(L, strerror(errno)); + lua_pushinteger(L, errno); + return 3; + } + + state->epoll_fd = epoll_fd; #else FD_ZERO(&state->wantread); FD_ZERO(&state->wantwrite); |