From a60da1f81d7faf717a122673e5cd1f2e3f42055b Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 14 Jul 2021 22:04:23 +0200 Subject: net.server_epoll: Log failures to set socket options Good to know if it fails, especially since the return value doesn't seem to be checked anywhere. Since LuaSec-wrapped sockets don't expose the setoption method, this will likely show when mod_c2s tries to enable keepalives on direct tls connections. --- net/server_epoll.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'net/server_epoll.lua') diff --git a/net/server_epoll.lua b/net/server_epoll.lua index f6a71379..8c26b4e6 100644 --- a/net/server_epoll.lua +++ b/net/server_epoll.lua @@ -281,9 +281,15 @@ end function interface:setoption(k, v) -- LuaSec doesn't expose setoption :( - if self.conn.setoption then - self.conn:setoption(k, v); + local ok, ret, err = pcall(self.conn.setoption, self.conn, k, v); + if not ok then + self:noise("Setting option %q = %q failed: %s", k, v, ret); + return ok, ret; + elseif not ret then + self:noise("Setting option %q = %q failed: %s", k, v, err); + return ret, err; end + return ret; end -- Timeout for detecting dead or idle sockets -- cgit v1.2.3