diff options
author | Kim Alvefur <zash@zash.se> | 2018-10-25 15:12:59 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2018-10-25 15:12:59 +0200 |
commit | 031dc2e2a0450b25e16bbc534b29522e0ee52793 (patch) | |
tree | f10f829a3a201917528af2117ebe78b410d1fab8 /net/server_epoll.lua | |
parent | e1846ef9a35e2e91a3c844ef489be780811aa1b0 (diff) | |
download | prosody-031dc2e2a0450b25e16bbc534b29522e0ee52793.tar.gz prosody-031dc2e2a0450b25e16bbc534b29522e0ee52793.zip |
net.server: Add an API for holding writes of outgoing data
Diffstat (limited to 'net/server_epoll.lua')
-rw-r--r-- | net/server_epoll.lua | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua index 4b40c7d5..cdf3e8fe 100644 --- a/net/server_epoll.lua +++ b/net/server_epoll.lua @@ -409,8 +409,10 @@ function interface:write(data) else self.writebuffer = { data }; end - self:setwritetimeout(); - self:set(nil, true); + if not self._write_lock then + self:setwritetimeout(); + self:set(nil, true); + end return #data; end interface.send = interface.write; @@ -590,6 +592,20 @@ function interface:pausefor(t) end); end +function interface:pause_writes() + self._write_lock = true; + self:setwritetimeout(false); + self:set(nil, false); +end + +function interface:resume_writes() + self._write_lock = nil; + if self.writebuffer[1] then + self:setwritetimeout(); + self:set(nil, true); + end +end + -- Connected! function interface:onconnect() if self.conn and not self.peername and self.conn.getpeername then |