Software /
code /
prosody
Changeset
11814:f27b9319e0da
net.server_epoll: Separate handling of "closed" from other errors
The intent is to ensure 'ondisconnect' only gets called once, while
giving buffered outgoing data a last chance to be delivered via the
:close() path in case the connection was only shutdown in one direction.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 22 Sep 2021 13:29:47 +0200 |
parents | 11813:790bffbb9047 |
children | 11815:df1d3df2204a |
files | net/server_epoll.lua |
diffstat | 1 files changed, 7 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/net/server_epoll.lua Wed Sep 22 11:27:55 2021 +0200 +++ b/net/server_epoll.lua Wed Sep 22 13:29:47 2021 +0200 @@ -456,14 +456,14 @@ self:onconnect(); self:onincoming(partial, err); end - if err ~= "timeout" then - if err == "closed" then - self:debug("Connection closed by remote"); - else - self:debug("Read error, closing (%s)", err); - end + if err == "closed" and self._connected then + self:debug("Connection closed by remote"); + self:close(err); + return; + elseif err ~= "timeout" then + self:debug("Read error, closing (%s)", err); self:on("disconnect", err); - self:close(); + self:destroy(); return; end end