From 8a2e65d5b79217cc0d4e453fe675ecd65d97928c Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 27 Nov 2023 08:19:52 +0100 Subject: util.poll: Rename things to clarify poll(2) limits With epoll(7), MAX_EVENTS controls how many events can be retrieved in one epoll_wait call, while with poll(2) this MAX_WATCHED controls how many sockets or other FDs can be watched at once. --- util-src/poll.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'util-src') diff --git a/util-src/poll.c b/util-src/poll.c index e69528fa..fc70bdb6 100644 --- a/util-src/poll.c +++ b/util-src/poll.c @@ -26,13 +26,15 @@ #include #include #ifndef MAX_EVENTS +/* Maximum number of returned events, retrieved into Lpoll_state */ #define MAX_EVENTS 256 #endif #endif #ifdef USE_POLL #include -#ifndef MAX_EVENTS -#define MAX_EVENTS 10000 +#ifndef MAX_WATCHED +/* Maximum number of watched sockets, kept in Lpoll_state */ +#define MAX_WATCHED 10000 #endif #endif #ifdef USE_SELECT @@ -59,7 +61,7 @@ typedef struct Lpoll_state { #endif #ifdef USE_POLL nfds_t count; - struct pollfd events[MAX_EVENTS]; + struct pollfd events[MAX_WATCHED]; #endif #ifdef USE_SELECT fd_set wantread; @@ -120,7 +122,7 @@ static int Ladd(lua_State *L) { } } - if(state->count >= MAX_EVENTS) { + if(state->count >= MAX_WATCHED) { luaL_pushfail(L); lua_pushstring(L, strerror(EMFILE)); lua_pushinteger(L, EMFILE); @@ -543,7 +545,7 @@ static int Lnew(lua_State *L) { state->processed = -1; state->count = 0; - for(nfds_t i = 0; i < MAX_EVENTS; i++) { + for(nfds_t i = 0; i < MAX_WATCHED; i++) { state->events[i].fd = -1; state->events[i].events = 0; state->events[i].revents = 0; -- cgit v1.2.3