aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-07-17 14:54:48 +0200
committerKim Alvefur <zash@zash.se>2021-07-17 14:54:48 +0200
commita30d4e15185f6eddd08de0179e4029e17a23d6c3 (patch)
tree8308f2b9223ea0d6e718c5ceb9b9b232fe672208
parentaba20a09bf1033b1f9c8ab2830d7d58970dd717f (diff)
downloadprosody-a30d4e15185f6eddd08de0179e4029e17a23d6c3.tar.gz
prosody-a30d4e15185f6eddd08de0179e4029e17a23d6c3.zip
net.server_epoll: Ensure timeouts match epoll flags
Read and write timeouts should usually match whether we want to read or write.
-rw-r--r--net/server_epoll.lua6
1 files changed, 6 insertions, 0 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua
index ae8a66bb..4670f670 100644
--- a/net/server_epoll.lua
+++ b/net/server_epoll.lua
@@ -430,6 +430,7 @@ function interface:onreadable()
err = "timeout";
elseif err == "wantwrite" then
self:set(nil, true);
+ self:setwritetimeout();
err = "timeout";
elseif err == "timeout" and not self._connected then
err = "connection timeout";
@@ -510,8 +511,10 @@ function interface:onwritable()
end
if err == "wantwrite" or err == "timeout" then
self:set(nil, true);
+ self:setwritetimeout();
elseif err == "wantread" then
self:set(true, nil);
+ self:setreadtimeout();
elseif err ~= "timeout" then
self:on("disconnect", err);
self:destroy();
@@ -553,6 +556,7 @@ interface.send = interface.write;
function interface:close()
if self.writebuffer and (self.writebuffer[1] or type(self.writebuffer) == "string") then
self:set(false, true); -- Flush final buffer contents
+ self:setreadtimeout(false);
self:setwritetimeout();
self.write, self.send = noop, noop; -- No more writing
self:debug("Close after writing remaining buffered data");
@@ -772,11 +776,13 @@ end
function interface:pause()
self:noise("Pause reading");
+ self:setreadtimeout(false);
return self:set(false);
end
function interface:resume()
self:noise("Resume reading");
+ self:setreadtimeout();
return self:set(true);
end