Software /
code /
prosody
Diff
net/server_epoll.lua @ 9581:1be99aedb0b3
net.server: Add an API for holding writes of outgoing data
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 25 Oct 2018 15:12:59 +0200 |
parent | 9573:57637247356d |
child | 9587:42eedef517dc |
line wrap: on
line diff
--- a/net/server_epoll.lua Sun Oct 28 17:11:18 2018 +0100 +++ b/net/server_epoll.lua Thu Oct 25 15:12:59 2018 +0200 @@ -409,8 +409,10 @@ 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 @@ 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