Software /
code /
prosody
Comparison
net/server_epoll.lua @ 8506:174fd716c9fa
server_epoll: Rework how socket readyness is detected
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 02 Feb 2018 23:46:00 +0100 |
parent | 8271:c09deab9989e |
child | 8507:71ef6d509105 |
comparison
equal
deleted
inserted
replaced
8505:c9bdb4dfed96 | 8506:174fd716c9fa |
---|---|
503 -- Initialization | 503 -- Initialization |
504 function interface:init() | 504 function interface:init() |
505 if self.tls and not self._tls then | 505 if self.tls and not self._tls then |
506 return self:starttls(); | 506 return self:starttls(); |
507 else | 507 else |
508 self.onwriteable = interface.onconnect; | 508 self.onwriteable = interface.onfirstwritable; |
509 self.onreadable = interface.onfirstreadable; | |
509 self:setwritetimeout(); | 510 self:setwritetimeout(); |
510 return self:setflags(false, true); | 511 return self:setflags(true, true); |
511 end | 512 end |
512 end | 513 end |
513 | 514 |
514 function interface:pause() | 515 function interface:pause() |
515 return self:setflags(false); | 516 return self:setflags(false); |
535 end); | 536 end); |
536 end | 537 end |
537 | 538 |
538 -- Connected! | 539 -- Connected! |
539 function interface:onconnect() | 540 function interface:onconnect() |
541 self:setflags(true, false); | |
542 self:on("connect"); | |
543 end | |
544 | |
545 function interface:onfirstwritable() | |
546 self.onreadable = nil; | |
540 self.onwriteable = nil; | 547 self.onwriteable = nil; |
541 self:setflags(true, false); | 548 self:onconnect(); |
542 if not self._connected then | |
543 self._connected = true; | |
544 self:on("connect"); | |
545 end | |
546 return self:onwriteable(); | 549 return self:onwriteable(); |
550 end | |
551 | |
552 function interface:onfirstreadable() | |
553 self.onreadable = nil; | |
554 self.onwriteable = nil; | |
555 self:onconnect(); | |
556 return self:onreadable(); | |
547 end | 557 end |
548 | 558 |
549 local function addserver(addr, port, listeners, pattern, tls) | 559 local function addserver(addr, port, listeners, pattern, tls) |
550 local conn, err = socket.bind(addr, port, cfg.tcp_backlog); | 560 local conn, err = socket.bind(addr, port, cfg.tcp_backlog); |
551 if not conn then return conn, err; end | 561 if not conn then return conn, err; end |