Skip to content

Commit 8392ec0

Browse files
truemedianzhaozg
authored andcommitted
Bump to Libuv 1.52.0
+ Adds `udp_open_ex`, which allows passing `reuseaddr` and `reuseport` options to `uv_udp_open`. + Adds `tcp_keepalive_ex`, which allows passing `KEEPINTVL` and `KEEPCNT` options to `uv_tcp_keepalive`. + Adds the `frsize` field to the statfs table, which contains the fragment size of the filesystem. + Adds the `UDP_REUSEPORT` constant to the constant table. The existing suite has no tests for `udp_open`, so I have not added any for `udp_open_ex`. Given that `uv_udp_open` just calls `uv_udp_open_ex` with default options, this change shouldn't cause any regressions.
1 parent b77e0d4 commit 8392ec0

File tree

11 files changed

+226
-2
lines changed

11 files changed

+226
-2
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10)
33
project (luv C ASM)
44

55
set(LUV_VERSION_MAJOR 1)
6-
set(LUV_VERSION_MINOR 51)
6+
set(LUV_VERSION_MINOR 52)
77
set(LUV_VERSION_PATCH 0)
88
set(LUV_VERSION ${LUV_VERSION_MAJOR}.${LUV_VERSION_MINOR}.${LUV_VERSION_PATCH})
99

deps/libuv

Submodule libuv updated 118 files

docs/docs.lua

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ local types = {
419419
{ 'bavail', 'integer' },
420420
{ 'files', 'integer' },
421421
{ 'ffree', 'integer' },
422+
{ 'frsize', opt('integer') },
422423
}),
423424

424425
['getrusage.result.time'] = table({
@@ -2219,6 +2220,23 @@ local doc = {
22192220
},
22202221
returns = success_ret,
22212222
},
2223+
{
2224+
name = 'tcp_keepalive_ex',
2225+
method_form = 'tcp:keepalive_ex(enable, [delay], [intvl], [cnt])',
2226+
desc = [[
2227+
Enable / disable TCP keep-alive with all socket options: TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT. `delay` is the value for TCP_KEEPIDLE, `intvl` is the value for TCP_KEEPINTVL, `cnt` is the value for TCP_KEEPCNT, ignored when `enable` is `false`.
2228+
2229+
With TCP keep-alive enabled, idle is the time (in seconds) the connection needs to remain idle before TCP starts sending keep-alive probes. intvl is the time (in seconds) between individual keep-alive probes. TCP will drop the connection after sending cnt probes without getting any replies from the peer, then the handle is destroyed with a UV_ETIMEDOUT error passed to the corresponding callback.
2230+
]],
2231+
params = {
2232+
{ name = 'tcp', type = 'uv_tcp_t' },
2233+
{ name = 'enable', type = 'boolean' },
2234+
{ name = 'delay', type = opt_int },
2235+
{ name = 'intvl', type = opt_int },
2236+
{ name = 'cnt', type = opt_int },
2237+
},
2238+
returns = success_ret,
2239+
},
22222240
{
22232241
name = 'tcp_simultaneous_accepts',
22242242
method_form = 'tcp:simultaneous_accepts(enable)',
@@ -2848,6 +2866,35 @@ local doc = {
28482866
},
28492867
returns = success_ret,
28502868
},
2869+
{
2870+
name = 'udp_open_ex',
2871+
method_form = 'udp:open_ex(fd, [flags])',
2872+
desc = [[
2873+
Opens an existing file descriptor or Windows SOCKET as a UDP handle.
2874+
2875+
Unix only: The only requirement of the sock argument is that it follows the
2876+
datagram contract (works in unconnected mode, supports sendmsg()/recvmsg(),
2877+
etc). In other words, other datagram-type sockets like raw sockets or netlink
2878+
sockets can also be passed to this function.
2879+
2880+
The file descriptor is set to non-blocking mode.
2881+
2882+
Note: The passed file descriptor or SOCKET is not checked for its type, but
2883+
it's required that it represents a valid datagram socket.
2884+
]],
2885+
params = {
2886+
{ name = 'udp', type = 'uv_udp_t' },
2887+
{ name = 'fd', type = 'integer' },
2888+
{
2889+
name = 'flags',
2890+
type = opt(union('integer', table({
2891+
{ 'reuseaddr', opt_bool },
2892+
{ 'reuseport', opt_bool },
2893+
}))),
2894+
},
2895+
},
2896+
returns = success_ret,
2897+
},
28512898
{
28522899
name = 'udp_bind',
28532900
method_form = 'udp:bind(host, port, [flags])',

docs/docs.md

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/meta.lua

Lines changed: 63 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/constants.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,10 @@ static int luv_constants(lua_State* L) {
347347
lua_pushinteger(L, UV_PIPE_NO_TRUNCATE);
348348
lua_setfield(L, -2, "PIPE_NO_TRUNCATE");
349349
#endif
350+
#if LUV_UV_VERSION_GEQ(1, 49, 0)
351+
lua_pushinteger(L, UV_UDP_REUSEPORT);
352+
lua_setfield(L, -2, "UDP_REUSEPORT");
353+
#endif
350354

351355
#if LUV_UV_VERSION_GEQ(1, 2, 0)
352356
lua_pushinteger(L, UV_TTY_MODE_NORMAL);

src/fs.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,10 @@ static void luv_push_statfs_table(lua_State* L, const uv_statfs_t* s) {
228228
lua_setfield(L, -2, "files");
229229
lua_pushinteger(L, s->f_ffree);
230230
lua_setfield(L, -2, "ffree");
231+
#if LUV_UV_VERSION_GEQ(1, 52, 0)
232+
lua_pushinteger(L, s->f_frsize);
233+
lua_setfield(L, -2, "frsize");
234+
#endif
231235
};
232236
#endif
233237

src/luv.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ static const luaL_Reg luv_functions[] = {
164164
{"tcp_open", luv_tcp_open},
165165
{"tcp_nodelay", luv_tcp_nodelay},
166166
{"tcp_keepalive", luv_tcp_keepalive},
167+
#if LUV_UV_VERSION_GEQ(1, 52, 0)
168+
{"tcp_keepalive_ex", luv_tcp_keepalive_ex},
169+
#endif
167170
{"tcp_simultaneous_accepts", luv_tcp_simultaneous_accepts},
168171
{"tcp_bind", luv_tcp_bind},
169172
{"tcp_getpeername", luv_tcp_getpeername},
@@ -215,6 +218,9 @@ static const luaL_Reg luv_functions[] = {
215218
{"udp_get_send_queue_size", luv_udp_get_send_queue_size},
216219
{"udp_get_send_queue_count", luv_udp_get_send_queue_count},
217220
{"udp_open", luv_udp_open},
221+
#if LUV_UV_VERSION_GEQ(1, 52, 0)
222+
{"udp_open_ex", luv_udp_open_ex},
223+
#endif
218224
{"udp_bind", luv_udp_bind},
219225
{"udp_getsockname", luv_udp_getsockname},
220226
{"udp_set_membership", luv_udp_set_membership},
@@ -556,6 +562,9 @@ static const luaL_Reg luv_tcp_methods[] = {
556562
{"open", luv_tcp_open},
557563
{"nodelay", luv_tcp_nodelay},
558564
{"keepalive", luv_tcp_keepalive},
565+
#if LUV_UV_VERSION_GEQ(1, 52, 0)
566+
{"keepalive_ex", luv_tcp_keepalive_ex},
567+
#endif
559568
{"simultaneous_accepts", luv_tcp_simultaneous_accepts},
560569
{"bind", luv_tcp_bind},
561570
{"getpeername", luv_tcp_getpeername},
@@ -590,6 +599,9 @@ static const luaL_Reg luv_udp_methods[] = {
590599
{"get_send_queue_size", luv_udp_get_send_queue_size},
591600
{"get_send_queue_count", luv_udp_get_send_queue_count},
592601
{"open", luv_udp_open},
602+
#if LUV_UV_VERSION_GEQ(1, 52, 0)
603+
{"open_ex", luv_udp_open_ex},
604+
#endif
593605
{"bind", luv_udp_bind},
594606
{"getsockname", luv_udp_getsockname},
595607
{"set_membership", luv_udp_set_membership},

src/tcp.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,25 @@ static int luv_tcp_keepalive(lua_State* L) {
8989
return luv_result(L, ret);
9090
}
9191

92+
#if LUV_UV_VERSION_GEQ(1, 52, 0)
93+
static int luv_tcp_keepalive_ex(lua_State* L) {
94+
uv_tcp_t* handle = luv_check_tcp(L, 1);
95+
int ret, enable;
96+
unsigned int delay = 0;
97+
unsigned int intvl = 1; // defaults chosen in uv_tcp_keepalive on libuv 1.52.0
98+
unsigned int cnt = 10; // defaults chosen in uv_tcp_keepalive on libuv 1.52.0
99+
luaL_checktype(L, 2, LUA_TBOOLEAN);
100+
enable = lua_toboolean(L, 2);
101+
if (enable) {
102+
delay = luaL_checkinteger(L, 3);
103+
intvl = luaL_optinteger(L, 4, intvl);
104+
cnt = luaL_optinteger(L, 5, cnt);
105+
}
106+
ret = uv_tcp_keepalive_ex(handle, enable, delay, intvl, cnt);
107+
return luv_result(L, ret);
108+
}
109+
#endif
110+
92111
static int luv_tcp_simultaneous_accepts(lua_State* L) {
93112
uv_tcp_t* handle = luv_check_tcp(L, 1);
94113
int ret, enable;

src/udp.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,31 @@ static int luv_udp_open(lua_State* L) {
130130
return luv_result(L, ret);
131131
}
132132

133+
#if LUV_UV_VERSION_GEQ(1, 52, 0)
134+
static int luv_udp_open_ex(lua_State* L) {
135+
uv_udp_t* handle = luv_check_udp(L, 1);
136+
uv_os_sock_t sock = luaL_checkinteger(L, 2);
137+
unsigned int flags = 0;
138+
if (!lua_isnoneornil(L, 3)) {
139+
if (lua_isinteger(L, 3)) {
140+
flags = (unsigned int)lua_tointeger(L, 3);
141+
} else if (lua_istable(L, 3)) {
142+
lua_getfield(L, 3, "reuseaddr");
143+
if (lua_toboolean(L, -1)) flags |= UV_UDP_REUSEADDR;
144+
lua_pop(L, 1);
145+
lua_getfield(L, 3, "reuseport");
146+
if (lua_toboolean(L, -1)) flags |= UV_UDP_REUSEPORT;
147+
lua_pop(L, 1);
148+
} else {
149+
return luaL_argerror(L, 3, "expected integer or table");
150+
}
151+
}
152+
153+
int ret = uv_udp_open_ex(handle, sock, flags);
154+
return luv_result(L, ret);
155+
}
156+
#endif
157+
133158
static int luv_udp_bind(lua_State* L) {
134159
uv_udp_t* handle = luv_check_udp(L, 1);
135160
const char* host = luaL_checkstring(L, 2);

0 commit comments

Comments
 (0)