From 05a9010c859b4d3caa4775d5a78fb1e287385617 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 6 Dec 2021 10:59:14 +0100 Subject: net.server_epoll: Ensure calls to :write() return something With opportunistic writes enabled, writes can return what :onwritable() returns, thus :onwritable() should return something sensible at each spot. Should prevent whatever caused > Error writing to connection: (nil) Tho this was probably harmless --- net/server_epoll.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/server_epoll.lua b/net/server_epoll.lua index 62fe3675..f61c204c 100644 --- a/net/server_epoll.lua +++ b/net/server_epoll.lua @@ -489,7 +489,7 @@ end function interface:onwritable() self._writing = true; -- prevent reentrant writes etc self:onconnect(); - if not self.conn then return; end -- could have been closed in onconnect + if not self.conn then return nil, "no-conn"; end -- could have been closed in onconnect self:on("predrain"); local buffer = self.writebuffer; local data = buffer or ""; @@ -542,6 +542,7 @@ function interface:onwritable() self:destroy(); return ok, err; end + return true, err; end -- The write buffer has been successfully emptied -- cgit v1.2.3