Comparison

net/server_epoll.lua @ 12084:59557bc3c4b8 0.11

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 Backport of 2bcd84123eba requested by Roi
author Kim Alvefur <zash@zash.se>
date Thu, 21 Oct 2021 15:59:16 +0200
parent 11811:ae43166fe931
child 12091:7a48ccb084dd
comparison
equal deleted inserted replaced
11844:0f786c4a2cb2 12084:59557bc3c4b8
769 -- Main loop 769 -- Main loop
770 local function loop(once) 770 local function loop(once)
771 repeat 771 repeat
772 local t = runtimers(cfg.max_wait, cfg.min_wait); 772 local t = runtimers(cfg.max_wait, cfg.min_wait);
773 local fd, r, w = poll:wait(t); 773 local fd, r, w = poll:wait(t);
774 if fd then 774 while fd do
775 local conn = fds[fd]; 775 local conn = fds[fd];
776 if conn then 776 if conn then
777 if r then 777 if r then
778 conn:onreadable(); 778 conn:onreadable();
779 end 779 end
782 end 782 end
783 else 783 else
784 log("debug", "Removing unknown fd %d", fd); 784 log("debug", "Removing unknown fd %d", fd);
785 poll:del(fd); 785 poll:del(fd);
786 end 786 end
787 elseif r ~= "timeout" and r ~= "signal" then 787 fd, r, w = poll:wait(0);
788 end
789 if r ~= "timeout" and r ~= "signal" then
788 log("debug", "epoll_wait error: %s[%d]", r, w); 790 log("debug", "epoll_wait error: %s[%d]", r, w);
789 end 791 end
790 until once or (quitting and next(fds) == nil); 792 until once or (quitting and next(fds) == nil);
791 return quitting; 793 return quitting;
792 end 794 end