Software /
code /
prosody
Comparison
util-src/poll.c @ 12315:cf2086a1bd45
util.poll: Expose API (epoll or select) used
Could he handy to know for debugging or decisions
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 27 Feb 2022 14:36:43 +0100 |
parent | 12314:898554323338 |
child | 12316:6bb2f660f689 |
comparison
equal
deleted
inserted
replaced
12314:898554323338 | 12315:cf2086a1bd45 |
---|---|
12 #include <string.h> | 12 #include <string.h> |
13 #include <errno.h> | 13 #include <errno.h> |
14 | 14 |
15 #if defined(__linux__) | 15 #if defined(__linux__) |
16 #define USE_EPOLL | 16 #define USE_EPOLL |
17 #define POLL_BACKEND "epoll" | |
17 #else | 18 #else |
18 #define USE_SELECT | 19 #define USE_SELECT |
20 #define POLL_BACKEND "select" | |
19 #endif | 21 #endif |
20 | 22 |
21 #ifdef USE_EPOLL | 23 #ifdef USE_EPOLL |
22 #include <sys/epoll.h> | 24 #include <sys/epoll.h> |
23 #ifndef MAX_EVENTS | 25 #ifndef MAX_EVENTS |
29 #endif | 31 #endif |
30 | 32 |
31 #include <lualib.h> | 33 #include <lualib.h> |
32 #include <lauxlib.h> | 34 #include <lauxlib.h> |
33 | 35 |
34 #ifdef USE_EPOLL | 36 #define STATE_MT "util.poll<" POLL_BACKEND ">" |
35 #define STATE_MT "util.poll<epoll>" | |
36 #endif | |
37 #ifdef USE_SELECT | |
38 #define STATE_MT "util.poll<select>" | |
39 #endif | |
40 | 37 |
41 #if (LUA_VERSION_NUM == 501) | 38 #if (LUA_VERSION_NUM == 501) |
42 #define luaL_setmetatable(L, tname) luaL_getmetatable(L, tname); lua_setmetatable(L, -2) | 39 #define luaL_setmetatable(L, tname) luaL_getmetatable(L, tname); lua_setmetatable(L, -2) |
43 #endif | 40 #endif |
44 #if (LUA_VERSION_NUM < 504) | 41 #if (LUA_VERSION_NUM < 504) |
485 lua_setfield(L, -2, #named_error); | 482 lua_setfield(L, -2, #named_error); |
486 | 483 |
487 push_errno(EEXIST); | 484 push_errno(EEXIST); |
488 push_errno(ENOENT); | 485 push_errno(ENOENT); |
489 | 486 |
490 } | 487 lua_pushliteral(L, POLL_BACKEND); |
491 return 1; | 488 lua_setfield(L, -2, "api"); |
492 } | 489 |
493 | 490 } |
491 return 1; | |
492 } | |
493 |