# HG changeset patch # User Matthew Wild # Date 1519399982 0 # Node ID 257fd322fc9feaf856429a2f7d0d6e214ccddce5 # Parent 67311cda0625700efe7c6941af2b50676c29fa49 net.server_event: Better outgoing connection error handling Same as 67311cda0625. Check for readability. If a socket is readable after initial connection, it likely means an error, so we call the readcallback for that connection to handle it (and ultimately close). diff -r 67311cda0625 -r 257fd322fc9f net/server_event.lua --- a/net/server_event.lua Fri Feb 23 15:30:00 2018 +0000 +++ b/net/server_event.lua Fri Feb 23 15:33:02 2018 +0000 @@ -105,6 +105,8 @@ self:ontimeout() -- call timeout listener self:_close() debug( "new connection failed. id:", self.id, "error:", self.fatalerror ) + elseif EV_READWRITE == event then + self.readcallback(event); else if plainssl and has_luasec then -- start ssl session self:starttls(self._sslctx, true) @@ -116,7 +118,7 @@ self.eventconnect = nil return -1 end - self.eventconnect = addevent( base, self.conn, EV_WRITE, callback, cfg.CONNECT_TIMEOUT ) + self.eventconnect = addevent( base, self.conn, EV_READWRITE, callback, cfg.CONNECT_TIMEOUT ) return true end function interface_mt:_start_session(call_onconnect) -- new session, for example after startssl