# HG changeset patch # User Kim Alvefur # Date 1470855594 -7200 # Node ID c2decf88e249e1b7c81c7b895353865803f0632d # Parent 4f3e4a092348338a33d4e5616548ce560088a79b net.server_epoll: Use first writable event to signal onconnect diff -r 4f3e4a092348 -r c2decf88e249 net/server_epoll.lua --- a/net/server_epoll.lua Wed Aug 10 20:57:05 2016 +0200 +++ b/net/server_epoll.lua Wed Aug 10 20:59:54 2016 +0200 @@ -374,6 +374,7 @@ created = gettime(); listeners = listeners; _pattern = pattern or server._pattern; + onwriteable = interface.onconnect; writebuffer = {}; tls = tls; }, interface_mt); @@ -397,8 +398,7 @@ client._tls = false; client:starttls(); else - self.listeners.onconnect(client); - client:setflags(true); + client:setflags(false, true); end client:setreadtimeout(); end @@ -419,9 +419,10 @@ end function interface:onconnect() - self.onreadable = nil; self.onwriteable = nil; self.listeners.onconnect(self); + self:setflags(true); + return self:onwriteable(); end local function addserver(addr, port, listeners, pattern, tls) @@ -451,7 +452,6 @@ _pattern = pattern; writebuffer = {}; tls = tls; - onreadable = interface.onconnect; onwriteable = interface.onconnect; peer = { addr, port }; }, interface_mt);