From 3b6565c77ba7bb4107bc00d1004bf8db6eaa1fe4 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 16 Jul 2021 00:57:42 +0200 Subject: net.server_epoll: Wrap LuaSocket object earlier to reuse option setting method Since it provides some protection and error handling in the form of logging. --- net/server_epoll.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'net') diff --git a/net/server_epoll.lua b/net/server_epoll.lua index d6b09de3..0d04f6ee 100644 --- a/net/server_epoll.lua +++ b/net/server_epoll.lua @@ -969,12 +969,12 @@ local function addclient(addr, port, listeners, read_size, tls_ctx, typ, extra) if not conn then return conn, err; end local ok, err = conn:settimeout(0); if not ok then return ok, err; end + local client = wrapsocket(conn, nil, read_size, listeners, tls_ctx, extra) if cfg.tcp_fastopen then - pcall(conn.setoption, conn, "tcp-fastopen-connect", 1); + client:setoption("tcp-fastopen-connect", 1); end local ok, err = conn:setpeername(addr, port); if not ok and err ~= "timeout" then return ok, err; end - local client = wrapsocket(conn, nil, read_size, listeners, tls_ctx, extra) client:updatenames(); local ok, err = client:init(); if not client.peername then -- cgit v1.2.3