Changeset

11695:1573099157c9

net.server_epoll: Propagate returns from opportunistic writes So that if a write ends up writing directly to the socket, it gets the actual return value
author Kim Alvefur <zash@zash.se>
date Fri, 16 Jul 2021 01:21:05 +0200
parents 11694:d6be4dda1f60
children 11696:917eca7be82b
files net/server_epoll.lua
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/net/server_epoll.lua	Thu Jul 15 01:38:44 2021 +0200
+++ b/net/server_epoll.lua	Fri Jul 16 01:21:05 2021 +0200
@@ -477,7 +477,7 @@
 		end
 		self:setwritetimeout(false);
 		self:ondrain(); -- Be aware of writes in ondrain
-		return;
+		return ok;
 	elseif partial then
 		self:debug("Sent %d out of %d buffered bytes", partial, #data);
 		buffer[1] = data:sub(partial+1);
@@ -494,6 +494,7 @@
 	elseif err ~= "timeout" then
 		self:on("disconnect", err);
 		self:destroy();
+		return ok, err;
 	end
 end
 
@@ -513,9 +514,9 @@
 	if not self._write_lock then
 		if cfg.opportunistic_writes and not self._opportunistic_write then
 			self._opportunistic_write = true;
-			self:onwritable();
+			local ret, err = self:onwritable();
 			self._opportunistic_write = nil;
-			return #data;
+			return ret, err;
 		end
 		self:setwritetimeout();
 		self:set(nil, true);