Software /
code /
prosody
Comparison
net/server_epoll.lua @ 11858:2bcd84123eba
net.server_epoll: Process all queued events from epoll before timers
Should call timers less frequently when many sockets are waiting for
processing. May help under heavy load.
Requested by Ge0rG
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 21 Oct 2021 15:59:16 +0200 |
parent | 11839:19b50ce9ef5a |
child | 11920:ff4e34c448a4 |
comparison
equal
deleted
inserted
replaced
11857:e080d6aa0b3b | 11858:2bcd84123eba |
---|---|
1031 -- Main loop | 1031 -- Main loop |
1032 local function loop(once) | 1032 local function loop(once) |
1033 repeat | 1033 repeat |
1034 local t = runtimers(cfg.max_wait, cfg.min_wait); | 1034 local t = runtimers(cfg.max_wait, cfg.min_wait); |
1035 local fd, r, w = poll:wait(t); | 1035 local fd, r, w = poll:wait(t); |
1036 if fd then | 1036 while fd do |
1037 local conn = fds[fd]; | 1037 local conn = fds[fd]; |
1038 if conn then | 1038 if conn then |
1039 if r then | 1039 if r then |
1040 conn:onreadable(); | 1040 conn:onreadable(); |
1041 end | 1041 end |
1044 end | 1044 end |
1045 else | 1045 else |
1046 log("debug", "Removing unknown fd %d", fd); | 1046 log("debug", "Removing unknown fd %d", fd); |
1047 poll:del(fd); | 1047 poll:del(fd); |
1048 end | 1048 end |
1049 elseif r ~= "timeout" and r ~= "signal" then | 1049 fd, r, w = poll:wait(0); |
1050 end | |
1051 if r ~= "timeout" and r ~= "signal" then | |
1050 log("debug", "epoll_wait error: %s[%d]", r, w); | 1052 log("debug", "epoll_wait error: %s[%d]", r, w); |
1051 end | 1053 end |
1052 until once or (quitting and next(fds) == nil); | 1054 until once or (quitting and next(fds) == nil); |
1053 return quitting; | 1055 return quitting; |
1054 end | 1056 end |