aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-11-27 08:19:52 +0100
committerKim Alvefur <zash@zash.se>2023-11-27 08:19:52 +0100
commit8a2e65d5b79217cc0d4e453fe675ecd65d97928c (patch)
treef52b733b43b5078f21fc43eccd969977905a06f9
parent97332bf56f6484c233472bb2da51deded00b737b (diff)
downloadprosody-8a2e65d5b79217cc0d4e453fe675ecd65d97928c.tar.gz
prosody-8a2e65d5b79217cc0d4e453fe675ecd65d97928c.zip
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.
-rw-r--r--util-src/poll.c12
1 files changed, 7 insertions, 5 deletions
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 <unistd.h>
#include <sys/epoll.h>
#ifndef MAX_EVENTS
+/* Maximum number of returned events, retrieved into Lpoll_state */
#define MAX_EVENTS 256
#endif
#endif
#ifdef USE_POLL
#include <poll.h>
-#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;