diff options
author | Kim Alvefur <zash@zash.se> | 2023-01-06 02:31:21 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2023-01-06 02:31:21 +0100 |
commit | 5acb354989a2474feed3d83446c098cf6b4ea311 (patch) | |
tree | 182203765754c497e057e37dccdbb92419f2a823 | |
parent | ffb390b759dfc07b09c055e1cc119d9a9ec40a1f (diff) | |
download | prosody-5acb354989a2474feed3d83446c098cf6b4ea311.tar.gz prosody-5acb354989a2474feed3d83446c098cf6b4ea311.zip |
net.server_epoll: Factor out single main loop step into its own function
This isn't actually used in Prosody, so no value in complicating the
real main loop because of it
-rw-r--r-- | net/server_epoll.lua | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua index b269bd9c..66a60b5e 100644 --- a/net/server_epoll.lua +++ b/net/server_epoll.lua @@ -1082,8 +1082,33 @@ local function setquitting(quit) end end +local function loop_once() + runtimers(); -- Ignore return value because we only do this once + local fd, r, w = poll:wait(0); + if fd then + local conn = fds[fd]; + if conn then + if r then + conn:onreadable(); + end + if w then + conn:onwritable(); + end + else + log("debug", "Removing unknown fd %d", fd); + poll:del(fd); + end + else + return fd, r; + end +end + -- Main loop local function loop(once) + if once then + return loop_once(); + end + repeat local t = runtimers(cfg.max_wait, cfg.min_wait); local fd, r, w = poll:wait(t); @@ -1105,7 +1130,7 @@ local function loop(once) if r ~= "timeout" and r ~= "signal" then log("debug", "epoll_wait error: %s[%d]", r, w); end - until once or (quitting and next(fds) == nil); + until (quitting and next(fds) == nil); return quitting; end |