aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-09-22 13:29:47 +0200
committerKim Alvefur <zash@zash.se>2021-09-22 13:29:47 +0200
commitd22a31530a94f4809d49ff51b2c3e984de7a087b (patch)
treeb24522a7593a73b47aee1bd2482dce817818d84a
parent7e8a3af45fd5448056ff016ddb171b20e791c43b (diff)
downloadprosody-d22a31530a94f4809d49ff51b2c3e984de7a087b.tar.gz
prosody-d22a31530a94f4809d49ff51b2c3e984de7a087b.zip
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.
-rw-r--r--net/server_epoll.lua14
1 files changed, 7 insertions, 7 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua
index ec2dd5b8..89b6ffe9 100644
--- a/net/server_epoll.lua
+++ b/net/server_epoll.lua
@@ -456,14 +456,14 @@ function interface:onreadable()
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