Software /
code /
prosody
Comparison
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 |
comparison
equal
deleted
inserted
replaced
9580:5fe91bfb734c | 9581:1be99aedb0b3 |
---|---|
407 if buffer then | 407 if buffer then |
408 t_insert(buffer, data); | 408 t_insert(buffer, data); |
409 else | 409 else |
410 self.writebuffer = { data }; | 410 self.writebuffer = { data }; |
411 end | 411 end |
412 self:setwritetimeout(); | 412 if not self._write_lock then |
413 self:set(nil, true); | 413 self:setwritetimeout(); |
414 self:set(nil, true); | |
415 end | |
414 return #data; | 416 return #data; |
415 end | 417 end |
416 interface.send = interface.write; | 418 interface.send = interface.write; |
417 | 419 |
418 -- Close, possibly after writing is done | 420 -- Close, possibly after writing is done |
588 end | 590 end |
589 self:set(true); | 591 self:set(true); |
590 end); | 592 end); |
591 end | 593 end |
592 | 594 |
595 function interface:pause_writes() | |
596 self._write_lock = true; | |
597 self:setwritetimeout(false); | |
598 self:set(nil, false); | |
599 end | |
600 | |
601 function interface:resume_writes() | |
602 self._write_lock = nil; | |
603 if self.writebuffer[1] then | |
604 self:setwritetimeout(); | |
605 self:set(nil, true); | |
606 end | |
607 end | |
608 | |
593 -- Connected! | 609 -- Connected! |
594 function interface:onconnect() | 610 function interface:onconnect() |
595 if self.conn and not self.peername and self.conn.getpeername then | 611 if self.conn and not self.peername and self.conn.getpeername then |
596 self.peername, self.peerport = self.conn:getpeername(); | 612 self.peername, self.peerport = self.conn:getpeername(); |
597 end | 613 end |