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
--- 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);