Software /
code /
prosody
Comparison
net/server_epoll.lua @ 11702:c206430e2643
net.server_epoll: Ensure timeouts match epoll flags
Read and write timeouts should usually match whether we want to read or
write.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 17 Jul 2021 14:54:48 +0200 |
parent | 11701:a3572205c5bf |
child | 11703:e57c5d9c722c |
comparison
equal
deleted
inserted
replaced
11701:a3572205c5bf | 11702:c206430e2643 |
---|---|
428 if err == "wantread" then | 428 if err == "wantread" then |
429 self:set(true, nil); | 429 self:set(true, nil); |
430 err = "timeout"; | 430 err = "timeout"; |
431 elseif err == "wantwrite" then | 431 elseif err == "wantwrite" then |
432 self:set(nil, true); | 432 self:set(nil, true); |
433 self:setwritetimeout(); | |
433 err = "timeout"; | 434 err = "timeout"; |
434 elseif err == "timeout" and not self._connected then | 435 elseif err == "timeout" and not self._connected then |
435 err = "connection timeout"; | 436 err = "connection timeout"; |
436 end | 437 end |
437 if partial and partial ~= "" then | 438 if partial and partial ~= "" then |
508 self:set(nil, true); | 509 self:set(nil, true); |
509 self:setwritetimeout(); | 510 self:setwritetimeout(); |
510 end | 511 end |
511 if err == "wantwrite" or err == "timeout" then | 512 if err == "wantwrite" or err == "timeout" then |
512 self:set(nil, true); | 513 self:set(nil, true); |
514 self:setwritetimeout(); | |
513 elseif err == "wantread" then | 515 elseif err == "wantread" then |
514 self:set(true, nil); | 516 self:set(true, nil); |
517 self:setreadtimeout(); | |
515 elseif err ~= "timeout" then | 518 elseif err ~= "timeout" then |
516 self:on("disconnect", err); | 519 self:on("disconnect", err); |
517 self:destroy(); | 520 self:destroy(); |
518 return ok, err; | 521 return ok, err; |
519 end | 522 end |
551 | 554 |
552 -- Close, possibly after writing is done | 555 -- Close, possibly after writing is done |
553 function interface:close() | 556 function interface:close() |
554 if self.writebuffer and (self.writebuffer[1] or type(self.writebuffer) == "string") then | 557 if self.writebuffer and (self.writebuffer[1] or type(self.writebuffer) == "string") then |
555 self:set(false, true); -- Flush final buffer contents | 558 self:set(false, true); -- Flush final buffer contents |
559 self:setreadtimeout(false); | |
556 self:setwritetimeout(); | 560 self:setwritetimeout(); |
557 self.write, self.send = noop, noop; -- No more writing | 561 self.write, self.send = noop, noop; -- No more writing |
558 self:debug("Close after writing remaining buffered data"); | 562 self:debug("Close after writing remaining buffered data"); |
559 self.ondrain = interface.close; | 563 self.ondrain = interface.close; |
560 else | 564 else |
770 end | 774 end |
771 end | 775 end |
772 | 776 |
773 function interface:pause() | 777 function interface:pause() |
774 self:noise("Pause reading"); | 778 self:noise("Pause reading"); |
779 self:setreadtimeout(false); | |
775 return self:set(false); | 780 return self:set(false); |
776 end | 781 end |
777 | 782 |
778 function interface:resume() | 783 function interface:resume() |
779 self:noise("Resume reading"); | 784 self:noise("Resume reading"); |
785 self:setreadtimeout(); | |
780 return self:set(true); | 786 return self:set(true); |
781 end | 787 end |
782 | 788 |
783 -- Pause connection for some time | 789 -- Pause connection for some time |
784 function interface:pausefor(t) | 790 function interface:pausefor(t) |