Software /
code /
prosody
Comparison
net/server_epoll.lua @ 12828:f33887f925e1
net.server_epoll: Remove delay on last main loop iteration when quitting
Main difference is that timers are not checked unconditionally before
each poll, only when running out of previous poll results (hidden by
util.poll). This removes a final poll at shutdown that usually delays
the 'not quitting' condition check by one second.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 06 Jan 2023 04:38:39 +0100 |
parent | 12827:0605d4f03e25 |
child | 12974:ba409c67353b |
comparison
equal
deleted
inserted
replaced
12827:0605d4f03e25 | 12828:f33887f925e1 |
---|---|
1107 local function loop(once) | 1107 local function loop(once) |
1108 if once then | 1108 if once then |
1109 return loop_once(); | 1109 return loop_once(); |
1110 end | 1110 end |
1111 | 1111 |
1112 repeat | 1112 local t = 0; |
1113 local t = runtimers(cfg.max_wait, cfg.min_wait); | 1113 while not quitting do |
1114 local fd, r, w = poll:wait(t); | 1114 local fd, r, w = poll:wait(t); |
1115 while fd do | 1115 if fd then |
1116 t = 0; | |
1116 local conn = fds[fd]; | 1117 local conn = fds[fd]; |
1117 if conn then | 1118 if conn then |
1118 if r then | 1119 if r then |
1119 conn:onreadable(); | 1120 conn:onreadable(); |
1120 end | 1121 end |
1123 end | 1124 end |
1124 else | 1125 else |
1125 log("debug", "Removing unknown fd %d", fd); | 1126 log("debug", "Removing unknown fd %d", fd); |
1126 poll:del(fd); | 1127 poll:del(fd); |
1127 end | 1128 end |
1128 fd, r, w = poll:wait(0); | 1129 elseif r == "timeout" then |
1129 end | 1130 t = runtimers(cfg.max_wait, cfg.min_wait); |
1130 if r ~= "timeout" and r ~= "signal" then | 1131 elseif r ~= "signal" then |
1131 log("debug", "epoll_wait error: %s[%d]", r, w); | 1132 log("debug", "epoll_wait error: %s[%d]", r, w); |
1132 end | 1133 end |
1133 until (quitting and next(fds) == nil); | 1134 end |
1134 return quitting; | 1135 return quitting; |
1135 end | 1136 end |
1136 | 1137 |
1137 return { | 1138 return { |
1138 get_backend = function () return "epoll"; end; | 1139 get_backend = function () return "epoll"; end; |