net.server_epoll: Handle LuaSec wantread/wantwrite conditions before callbacks (fixes #1333) 0.11
authorKim Alvefur <zash@zash.se>
Thu, 28 Mar 2019 12:31:14 +0100
branch0.11
changeset 9935 485231f8b75d
parent 9885 68faa0c1a99c
child 9936 df73ca804719
net.server_epoll: Handle LuaSec wantread/wantwrite conditions before callbacks (fixes #1333) This prevents the :set(true) call from resuming a connection that was paused in the onincoming callback.
net/server_epoll.lua
--- a/net/server_epoll.lua	Mon Jan 14 00:17:02 2019 +0100
+++ b/net/server_epoll.lua	Thu Mar 28 12:31:14 2019 +0100
@@ -355,15 +355,18 @@
 		self:onconnect();
 		self:on("incoming", data);
 	else
+		if err == "wantread" then
+			self:set(true, nil);
+			err = "timeout";
+		elseif err == "wantwrite" then
+			self:set(nil, true);
+			err = "timeout";
+		end
 		if partial and partial ~= "" then
 			self:onconnect();
 			self:on("incoming", partial, err);
 		end
-		if err == "wantread" then
-			self:set(true, nil);
-		elseif err == "wantwrite" then
-			self:set(nil, true);
-		elseif err ~= "timeout" then
+		if err ~= "timeout" then
 			self:on("disconnect", err);
 			self:destroy()
 			return;