Software /
code /
prosody
Comparison
net/server_epoll.lua @ 11814:f27b9319e0da
net.server_epoll: Separate handling of "closed" from other errors
The intent is to ensure 'ondisconnect' only gets called once, while
giving buffered outgoing data a last chance to be delivered via the
:close() path in case the connection was only shutdown in one direction.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 22 Sep 2021 13:29:47 +0200 |
parent | 11813:790bffbb9047 |
child | 11839:19b50ce9ef5a |
comparison
equal
deleted
inserted
replaced
11813:790bffbb9047 | 11814:f27b9319e0da |
---|---|
454 end | 454 end |
455 if partial and partial ~= "" then | 455 if partial and partial ~= "" then |
456 self:onconnect(); | 456 self:onconnect(); |
457 self:onincoming(partial, err); | 457 self:onincoming(partial, err); |
458 end | 458 end |
459 if err ~= "timeout" then | 459 if err == "closed" and self._connected then |
460 if err == "closed" then | 460 self:debug("Connection closed by remote"); |
461 self:debug("Connection closed by remote"); | 461 self:close(err); |
462 else | 462 return; |
463 self:debug("Read error, closing (%s)", err); | 463 elseif err ~= "timeout" then |
464 end | 464 self:debug("Read error, closing (%s)", err); |
465 self:on("disconnect", err); | 465 self:on("disconnect", err); |
466 self:close(); | 466 self:destroy(); |
467 return; | 467 return; |
468 end | 468 end |
469 end | 469 end |
470 if not self.conn then return; end | 470 if not self.conn then return; end |
471 if self._limit and (data or partial) then | 471 if self._limit and (data or partial) then |