# HG changeset patch # User Kim Alvefur # Date 1483295658 -3600 # Node ID d0c32d86724f98acb86e9cfe5fc2e9eb06530484 # Parent 12609aee3b3bbf94afaebe49a365f85ee03e4339 server_epoll: Flush and close all connections before quitting mainloop so no data is lost in buffers diff -r 12609aee3b3b -r d0c32d86724f net/server_epoll.lua --- a/net/server_epoll.lua Sun Jan 01 19:33:38 2017 +0100 +++ b/net/server_epoll.lua Sun Jan 01 19:34:18 2017 +0100 @@ -15,6 +15,7 @@ local setmetatable = setmetatable; local tostring = tostring; local pcall = pcall; +local next = next; local pairs = pairs; local log = require "util.logger".init("server_epoll"); local epoll = require "epoll"; @@ -615,6 +616,7 @@ local function setquitting(quit) if quit then quitting = "quitting"; + closeall(); else quitting = nil; end @@ -641,7 +643,7 @@ elseif r ~= "timeout" then log("debug", "epoll_wait error: %s", tostring(r)); end - until once or quitting; + until once or (quitting and next(fds) == nil); return quitting; end