Mercurial > prosody-hg
comparison net/server_epoll.lua @ 7626:e56343d50293
net.server_epoll: Tailcalls
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 22 Aug 2016 17:20:54 +0200 |
| parents | 6afafd6d4ef0 |
| children | d8126298c729 |
comparison
equal
deleted
inserted
replaced
| 7625:6afafd6d4ef0 | 7626:e56343d50293 |
|---|---|
| 477 function interface:init() | 477 function interface:init() |
| 478 if self.tls and not self._tls then | 478 if self.tls and not self._tls then |
| 479 self._tls = false; -- This means we should call onconnect when TLS is up | 479 self._tls = false; -- This means we should call onconnect when TLS is up |
| 480 return self:starttls(); | 480 return self:starttls(); |
| 481 else | 481 else |
| 482 self:setflags(false, true); | 482 self.onwriteable = interface.onconnect; |
| 483 self:setwritetimeout(cfg.connect_timeout); | 483 self:setwritetimeout(); |
| 484 return self:setflags(false, true); | |
| 484 end | 485 end |
| 485 end | 486 end |
| 486 | 487 |
| 487 function interface:pause() | 488 function interface:pause() |
| 488 self:setflags(false); | 489 return self:setflags(false); |
| 489 end | 490 end |
| 490 | 491 |
| 491 function interface:resume() | 492 function interface:resume() |
| 492 self:setflags(true); | 493 return self:setflags(true); |
| 493 end | 494 end |
| 494 | 495 |
| 495 -- Pause connection for some time | 496 -- Pause connection for some time |
| 496 function interface:pausefor(t) | 497 function interface:pausefor(t) |
| 497 if self._pausefor then | 498 if self._pausefor then |
| 499 end | 500 end |
| 500 if t == false then return; end | 501 if t == false then return; end |
| 501 self:setflags(false); | 502 self:setflags(false); |
| 502 self._pausefor = addtimer(t, function () | 503 self._pausefor = addtimer(t, function () |
| 503 self._pausefor = nil; | 504 self._pausefor = nil; |
| 504 self:setflags(true); | |
| 505 if self.conn:dirty() then | 505 if self.conn:dirty() then |
| 506 self:onreadable(); | 506 self:onreadable(); |
| 507 end | 507 end |
| 508 return self:setflags(true); | |
| 508 end); | 509 end); |
| 509 end | 510 end |
| 510 | 511 |
| 511 function interface:onconnect() | 512 function interface:onconnect() |
| 512 self.onwriteable = nil; | 513 self.onwriteable = nil; |
