Changeset

7554:c2decf88e249

net.server_epoll: Use first writable event to signal onconnect
author Kim Alvefur <zash@zash.se>
date Wed, 10 Aug 2016 20:59:54 +0200
parents 7553:4f3e4a092348
children 7555:f3abb5f891eb
files net/server_epoll.lua
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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);