Software /
code /
prosody
Comparison
util-src/poll.c @ 9476:f3935aa4cc7e
util.poll: Handle failed epoll FD creation
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 11 Oct 2018 18:52:12 +0200 |
parent | 9475:9b26a50cdfe3 |
child | 9478:bd178ed0459b |
comparison
equal
deleted
inserted
replaced
9475:9b26a50cdfe3 | 9476:f3935aa4cc7e |
---|---|
384 Lpoll_state *state = lua_newuserdata(L, sizeof(Lpoll_state)); | 384 Lpoll_state *state = lua_newuserdata(L, sizeof(Lpoll_state)); |
385 luaL_setmetatable(L, STATE_MT); | 385 luaL_setmetatable(L, STATE_MT); |
386 | 386 |
387 /* Initialize state */ | 387 /* Initialize state */ |
388 #ifdef USE_EPOLL | 388 #ifdef USE_EPOLL |
389 state->epoll_fd = epoll_create1(0); | 389 state->epoll_fd = -1; |
390 state->processed = 0; | 390 state->processed = 0; |
391 | |
392 int epoll_fd = epoll_create1(EPOLL_CLOEXEC); | |
393 | |
394 if(epoll_fd <= 0) { | |
395 lua_pushnil(L); | |
396 lua_pushstring(L, strerror(errno)); | |
397 lua_pushinteger(L, errno); | |
398 return 3; | |
399 } | |
400 | |
401 state->epoll_fd = epoll_fd; | |
391 #else | 402 #else |
392 FD_ZERO(&state->wantread); | 403 FD_ZERO(&state->wantread); |
393 FD_ZERO(&state->wantwrite); | 404 FD_ZERO(&state->wantwrite); |
394 FD_ZERO(&state->readable); | 405 FD_ZERO(&state->readable); |
395 FD_ZERO(&state->writable); | 406 FD_ZERO(&state->writable); |