Comparison

net/server_epoll.lua @ 11592:64cfa396bb84

net.server_epoll: Fix reporting of socket connect timeout If the underlying TCP connection times out before the write timeout kicks in, end up here with err="timeout", which the following code treats as a minor issue. Then, due to epoll apparently returning the EPOLLOUT (writable) event too, we go on and try to write to the socket (commonly stream headers). This fails because the socket is closed, which becomes the error returned up the stack to the rest of Prosody. This also trips the 'onconnect' signal, which has effects on various things, such as the net.connect state machine. Probably undesirable effects. With this, we instead return "connection timeout", like server_event, and destroy the connection handle properly. And then nothing else happens because the connection has been destroyed.
author Kim Alvefur <zash@zash.se>
date Mon, 07 Jun 2021 17:37:14 +0200
parent 11497:960674938665
child 11595:8985efc6792d
comparison
equal deleted inserted replaced
11591:e7a964572f6b 11592:64cfa396bb84
414 self:set(true, nil); 414 self:set(true, nil);
415 err = "timeout"; 415 err = "timeout";
416 elseif err == "wantwrite" then 416 elseif err == "wantwrite" then
417 self:set(nil, true); 417 self:set(nil, true);
418 err = "timeout"; 418 err = "timeout";
419 elseif err == "timeout" and not self._connected then
420 err = "connection timeout";
419 end 421 end
420 if partial and partial ~= "" then 422 if partial and partial ~= "" then
421 self:onconnect(); 423 self:onconnect();
422 self:onincoming(partial, err); 424 self:onincoming(partial, err);
423 end 425 end