aboutsummaryrefslogtreecommitdiffstats
path: root/net/server_epoll.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-08-14 13:07:29 +0200
committerKim Alvefur <zash@zash.se>2021-08-14 13:07:29 +0200
commitd4b9f814fe698f60a2b08f27f45d2aab4d2523e7 (patch)
tree8e25fbc0be8dc3c987913a1b617b4ee187aa7135 /net/server_epoll.lua
parenta049793c95cf03587465b5536fd6e962b3c92331 (diff)
downloadprosody-d4b9f814fe698f60a2b08f27f45d2aab4d2523e7.tar.gz
prosody-d4b9f814fe698f60a2b08f27f45d2aab4d2523e7.zip
net.server_epoll: Improve efficiency of opportunistic writes
Should prevent further opportunistic write attempts after the kernel buffers are full and stops accepting writes. When combined with `keep_buffers = false` it should stop it from repeatedly recreating the buffer table and concatenating it back into a string when there's a lot to write.
Diffstat (limited to 'net/server_epoll.lua')
-rw-r--r--net/server_epoll.lua4
1 files changed, 3 insertions, 1 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua
index 7b6f4680..b737ee59 100644
--- a/net/server_epoll.lua
+++ b/net/server_epoll.lua
@@ -484,6 +484,7 @@ function interface:onwritable()
end
end
local ok, err, partial = self.conn:send(data);
+ self._writable = ok;
if ok then
self:set(nil, false);
if cfg.keep_buffers and type(buffer) == "table" then
@@ -539,7 +540,7 @@ function interface:write(data)
self.writebuffer = data;
end
if not self._write_lock then
- if cfg.opportunistic_writes and not self._opportunistic_write then
+ if self._writable and cfg.opportunistic_writes and not self._opportunistic_write then
self._opportunistic_write = true;
local ret, err = self:onwritable();
self._opportunistic_write = nil;
@@ -745,6 +746,7 @@ function interface:onacceptable()
local client = wrapsocket(conn, self, nil, self.listeners);
client:debug("New connection %s on server %s", client, self);
client:defaultoptions();
+ client._writable = cfg.opportunistic_writes;
if self.tls_direct then
client:add(true, true);
client:inittls(self.tls_ctx, true);