Software /
code /
prosody
Comparison
net/server_epoll.lua @ 12514:194469fb46f9
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 16 Jul 2021 00:57:42 +0200 |
parent | 12513:6efbcd52db21 |
child | 12515:76c1725f4467 |
comparison
equal
deleted
inserted
replaced
12513:6efbcd52db21 | 12514:194469fb46f9 |
---|---|
967 end | 967 end |
968 local conn, err = create(); | 968 local conn, err = create(); |
969 if not conn then return conn, err; end | 969 if not conn then return conn, err; end |
970 local ok, err = conn:settimeout(0); | 970 local ok, err = conn:settimeout(0); |
971 if not ok then return ok, err; end | 971 if not ok then return ok, err; end |
972 local client = wrapsocket(conn, nil, read_size, listeners, tls_ctx, extra) | |
972 if cfg.tcp_fastopen then | 973 if cfg.tcp_fastopen then |
973 pcall(conn.setoption, conn, "tcp-fastopen-connect", 1); | 974 client:setoption("tcp-fastopen-connect", 1); |
974 end | 975 end |
975 local ok, err = conn:setpeername(addr, port); | 976 local ok, err = conn:setpeername(addr, port); |
976 if not ok and err ~= "timeout" then return ok, err; end | 977 if not ok and err ~= "timeout" then return ok, err; end |
977 local client = wrapsocket(conn, nil, read_size, listeners, tls_ctx, extra) | |
978 client:updatenames(); | 978 client:updatenames(); |
979 local ok, err = client:init(); | 979 local ok, err = client:init(); |
980 if not client.peername then | 980 if not client.peername then |
981 -- otherwise not set until connected | 981 -- otherwise not set until connected |
982 client.peername, client.peerport = addr, port; | 982 client.peername, client.peerport = addr, port; |