From 38c7b5161b0c174050a0869a556e39bc499b1fa0 Mon Sep 17 00:00:00 2001 From: goldenstein64 Date: Tue, 26 Jul 2022 16:24:25 -0400 Subject: [PATCH 1/3] fix(rockspec): Fixup Windows (mingw32) builds (#383) --- rockspecs/luasocket-3.0.0-1.rockspec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rockspecs/luasocket-3.0.0-1.rockspec b/rockspecs/luasocket-3.0.0-1.rockspec index 4cf4acf..d64731a 100644 --- a/rockspecs/luasocket-3.0.0-1.rockspec +++ b/rockspecs/luasocket-3.0.0-1.rockspec @@ -34,7 +34,7 @@ local function make_plat(plat) }, mingw32 = { "LUASOCKET_DEBUG", - "LUASOCKET_INET_PTON", + -- "LUASOCKET_INET_PTON", "WINVER=0x0501" } } @@ -113,6 +113,7 @@ local function make_plat(plat) then modules["socket.core"].sources[#modules["socket.core"].sources+1] = "src/wsocket.c" modules["socket.core"].libraries = { "ws2_32" } + modules["socket.core"].libdirs = {} end return { modules = modules } end From cff09ffb326237fd2edd848b6911521fe3e3d3fc Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 26 Jul 2022 23:39:17 +0300 Subject: [PATCH 2/3] chore(rockspec): Move recent PR change to proper rockspec (#384) --- luasocket-scm-3.rockspec | 3 ++- rockspecs/luasocket-3.0.0-1.rockspec | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/luasocket-scm-3.rockspec b/luasocket-scm-3.rockspec index 71f335c..1045251 100644 --- a/luasocket-scm-3.rockspec +++ b/luasocket-scm-3.rockspec @@ -34,7 +34,7 @@ local function make_plat(plat) }, mingw32 = { "LUASOCKET_DEBUG", - "LUASOCKET_INET_PTON", + -- "LUASOCKET_INET_PTON", "WINVER=0x0501" } } @@ -113,6 +113,7 @@ local function make_plat(plat) then modules["socket.core"].sources[#modules["socket.core"].sources+1] = "src/wsocket.c" modules["socket.core"].libraries = { "ws2_32" } + modules["socket.core"].libdirs = {} end return { modules = modules } end diff --git a/rockspecs/luasocket-3.0.0-1.rockspec b/rockspecs/luasocket-3.0.0-1.rockspec index d64731a..4cf4acf 100644 --- a/rockspecs/luasocket-3.0.0-1.rockspec +++ b/rockspecs/luasocket-3.0.0-1.rockspec @@ -34,7 +34,7 @@ local function make_plat(plat) }, mingw32 = { "LUASOCKET_DEBUG", - -- "LUASOCKET_INET_PTON", + "LUASOCKET_INET_PTON", "WINVER=0x0501" } } @@ -113,7 +113,6 @@ local function make_plat(plat) then modules["socket.core"].sources[#modules["socket.core"].sources+1] = "src/wsocket.c" modules["socket.core"].libraries = { "ws2_32" } - modules["socket.core"].libdirs = {} end return { modules = modules } end From 0c7df119c2b71bed814db7b3da8fc379131433fe Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 27 Jul 2022 08:16:43 +0200 Subject: [PATCH 3/3] feat(tcp): Add support for TCP Fast Open --- docs/tcp.html | 4 ++++ src/options.c | 16 ++++++++++++++++ src/options.h | 7 +++++++ src/tcp.c | 6 ++++++ 4 files changed, 33 insertions(+) diff --git a/docs/tcp.html b/docs/tcp.html index 9cc173e..f15196c 100644 --- a/docs/tcp.html +++ b/docs/tcp.html @@ -485,6 +485,10 @@ disables the Nagle's algorithm for the connection;
  • 'tcp-keepintvl': value for TCP_KEEPINTVL Linux only!!
  • +
  • 'tcp-fastopen': value for TCP_FASTOPEN Linux only!!
  • + +
  • 'tcp-fastopen-connect': value for TCP_FASTOPEN_CONNECT Linux only!!
  • +
  • 'ipv6-v6only': Setting this option to true restricts an inet6 socket to sending and receiving only IPv6 packets.
  • diff --git a/src/options.c b/src/options.c index 2b53c67..51ea351 100644 --- a/src/options.c +++ b/src/options.c @@ -190,6 +190,22 @@ int opt_set_send_buf_size(lua_State *L, p_socket ps) return opt_setint(L, ps, SOL_SOCKET, SO_SNDBUF); } +// /*------------------------------------------------------*/ + +#ifdef TCP_FASTOPEN +int opt_set_tcp_fastopen(lua_State *L, p_socket ps) +{ + return opt_setint(L, ps, IPPROTO_TCP, TCP_FASTOPEN); +} +#endif + +#ifdef TCP_FASTOPEN_CONNECT +int opt_set_tcp_fastopen_connect(lua_State *L, p_socket ps) +{ + return opt_setint(L, ps, IPPROTO_TCP, TCP_FASTOPEN_CONNECT); +} +#endif + /*------------------------------------------------------*/ int opt_set_ip6_unicast_hops(lua_State *L, p_socket ps) { diff --git a/src/options.h b/src/options.h index 41f7337..a4d5d75 100644 --- a/src/options.h +++ b/src/options.h @@ -64,6 +64,13 @@ int opt_get_recv_buf_size(lua_State *L, p_socket ps); int opt_set_send_buf_size(lua_State *L, p_socket ps); int opt_get_send_buf_size(lua_State *L, p_socket ps); +#ifdef TCP_FASTOPEN +int opt_set_tcp_fastopen(lua_State *L, p_socket ps); +#endif +#ifdef TCP_FASTOPEN_CONNECT +int opt_set_tcp_fastopen_connect(lua_State *L, p_socket ps); +#endif + int opt_set_ip6_unicast_hops(lua_State *L, p_socket ps); int opt_get_ip6_unicast_hops(lua_State *L, p_socket ps); diff --git a/src/tcp.c b/src/tcp.c index 5876bfb..e24cb0c 100644 --- a/src/tcp.c +++ b/src/tcp.c @@ -109,6 +109,12 @@ static t_opt optset[] = { {"linger", opt_set_linger}, {"recv-buffer-size", opt_set_recv_buf_size}, {"send-buffer-size", opt_set_send_buf_size}, +#ifdef TCP_FASTOPEN + {"tcp-fastopen", opt_set_tcp_fastopen}, +#endif +#ifdef TCP_FASTOPEN_CONNECT + {"tcp-fastopen-connect", opt_set_tcp_fastopen_connect}, +#endif {NULL, NULL} };