Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10)
project (luv C ASM)

set(LUV_VERSION_MAJOR 1)
set(LUV_VERSION_MINOR 51)
set(LUV_VERSION_MINOR 52)
set(LUV_VERSION_PATCH 0)
set(LUV_VERSION ${LUV_VERSION_MAJOR}.${LUV_VERSION_MINOR}.${LUV_VERSION_PATCH})

Expand Down
2 changes: 1 addition & 1 deletion deps/libuv
Submodule libuv updated 118 files
47 changes: 47 additions & 0 deletions docs/docs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ local types = {
{ 'bavail', 'integer' },
{ 'files', 'integer' },
{ 'ffree', 'integer' },
{ 'frsize', opt('integer') },
}),

['getrusage.result.time'] = table({
Expand Down Expand Up @@ -2219,6 +2220,23 @@ local doc = {
},
returns = success_ret,
},
{
name = 'tcp_keepalive_ex',
method_form = 'tcp:keepalive_ex(enable, [delay], [intvl], [cnt])',
desc = [[
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`.

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.
]],
params = {
{ name = 'tcp', type = 'uv_tcp_t' },
{ name = 'enable', type = 'boolean' },
{ name = 'delay', type = opt_int },
{ name = 'intvl', type = opt_int },
{ name = 'cnt', type = opt_int },
},
returns = success_ret,
},
{
name = 'tcp_simultaneous_accepts',
method_form = 'tcp:simultaneous_accepts(enable)',
Expand Down Expand Up @@ -2848,6 +2866,35 @@ local doc = {
},
returns = success_ret,
},
{
name = 'udp_open_ex',
method_form = 'udp:open_ex(fd, [flags])',
desc = [[
Opens an existing file descriptor or Windows SOCKET as a UDP handle.

Unix only: The only requirement of the sock argument is that it follows the
datagram contract (works in unconnected mode, supports sendmsg()/recvmsg(),
etc). In other words, other datagram-type sockets like raw sockets or netlink
sockets can also be passed to this function.

The file descriptor is set to non-blocking mode.

Note: The passed file descriptor or SOCKET is not checked for its type, but
it's required that it represents a valid datagram socket.
]],
params = {
{ name = 'udp', type = 'uv_udp_t' },
{ name = 'fd', type = 'integer' },
{
name = 'flags',
type = opt(union('integer', table({
{ 'reuseaddr', opt_bool },
{ 'reuseport', opt_bool },
}))),
},
},
returns = success_ret,
},
{
name = 'udp_bind',
method_form = 'udp:bind(host, port, [flags])',
Expand Down
44 changes: 44 additions & 0 deletions docs/docs.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 63 additions & 0 deletions docs/meta.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@ static int luv_constants(lua_State* L) {
lua_pushinteger(L, UV_PIPE_NO_TRUNCATE);
lua_setfield(L, -2, "PIPE_NO_TRUNCATE");
#endif
#if LUV_UV_VERSION_GEQ(1, 49, 0)
lua_pushinteger(L, UV_UDP_REUSEPORT);
lua_setfield(L, -2, "UDP_REUSEPORT");
#endif

#if LUV_UV_VERSION_GEQ(1, 2, 0)
lua_pushinteger(L, UV_TTY_MODE_NORMAL);
Expand Down
4 changes: 4 additions & 0 deletions src/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ static void luv_push_statfs_table(lua_State* L, const uv_statfs_t* s) {
lua_setfield(L, -2, "files");
lua_pushinteger(L, s->f_ffree);
lua_setfield(L, -2, "ffree");
#if LUV_UV_VERSION_GEQ(1, 52, 0)
lua_pushinteger(L, s->f_frsize);
lua_setfield(L, -2, "frsize");
#endif
};
#endif

Expand Down
12 changes: 12 additions & 0 deletions src/luv.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ static const luaL_Reg luv_functions[] = {
{"tcp_open", luv_tcp_open},
{"tcp_nodelay", luv_tcp_nodelay},
{"tcp_keepalive", luv_tcp_keepalive},
#if LUV_UV_VERSION_GEQ(1, 52, 0)
{"tcp_keepalive_ex", luv_tcp_keepalive_ex},
#endif
{"tcp_simultaneous_accepts", luv_tcp_simultaneous_accepts},
{"tcp_bind", luv_tcp_bind},
{"tcp_getpeername", luv_tcp_getpeername},
Expand Down Expand Up @@ -215,6 +218,9 @@ static const luaL_Reg luv_functions[] = {
{"udp_get_send_queue_size", luv_udp_get_send_queue_size},
{"udp_get_send_queue_count", luv_udp_get_send_queue_count},
{"udp_open", luv_udp_open},
#if LUV_UV_VERSION_GEQ(1, 52, 0)
{"udp_open_ex", luv_udp_open_ex},
#endif
{"udp_bind", luv_udp_bind},
{"udp_getsockname", luv_udp_getsockname},
{"udp_set_membership", luv_udp_set_membership},
Expand Down Expand Up @@ -556,6 +562,9 @@ static const luaL_Reg luv_tcp_methods[] = {
{"open", luv_tcp_open},
{"nodelay", luv_tcp_nodelay},
{"keepalive", luv_tcp_keepalive},
#if LUV_UV_VERSION_GEQ(1, 52, 0)
{"keepalive_ex", luv_tcp_keepalive_ex},
#endif
{"simultaneous_accepts", luv_tcp_simultaneous_accepts},
{"bind", luv_tcp_bind},
{"getpeername", luv_tcp_getpeername},
Expand Down Expand Up @@ -590,6 +599,9 @@ static const luaL_Reg luv_udp_methods[] = {
{"get_send_queue_size", luv_udp_get_send_queue_size},
{"get_send_queue_count", luv_udp_get_send_queue_count},
{"open", luv_udp_open},
#if LUV_UV_VERSION_GEQ(1, 52, 0)
{"open_ex", luv_udp_open_ex},
#endif
{"bind", luv_udp_bind},
{"getsockname", luv_udp_getsockname},
{"set_membership", luv_udp_set_membership},
Expand Down
19 changes: 19 additions & 0 deletions src/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,25 @@ static int luv_tcp_keepalive(lua_State* L) {
return luv_result(L, ret);
}

#if LUV_UV_VERSION_GEQ(1, 52, 0)
static int luv_tcp_keepalive_ex(lua_State* L) {
uv_tcp_t* handle = luv_check_tcp(L, 1);
int ret, enable;
unsigned int delay = 0;
unsigned int intvl = 1; // defaults chosen in uv_tcp_keepalive on libuv 1.52.0
unsigned int cnt = 10; // defaults chosen in uv_tcp_keepalive on libuv 1.52.0
luaL_checktype(L, 2, LUA_TBOOLEAN);
enable = lua_toboolean(L, 2);
if (enable) {
delay = luaL_checkinteger(L, 3);
intvl = luaL_optinteger(L, 4, intvl);
cnt = luaL_optinteger(L, 5, cnt);
}
ret = uv_tcp_keepalive_ex(handle, enable, delay, intvl, cnt);
return luv_result(L, ret);
}
#endif

static int luv_tcp_simultaneous_accepts(lua_State* L) {
uv_tcp_t* handle = luv_check_tcp(L, 1);
int ret, enable;
Expand Down
25 changes: 25 additions & 0 deletions src/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,31 @@ static int luv_udp_open(lua_State* L) {
return luv_result(L, ret);
}

#if LUV_UV_VERSION_GEQ(1, 52, 0)
static int luv_udp_open_ex(lua_State* L) {
uv_udp_t* handle = luv_check_udp(L, 1);
uv_os_sock_t sock = luaL_checkinteger(L, 2);
unsigned int flags = 0;
if (!lua_isnoneornil(L, 3)) {
if (lua_isinteger(L, 3)) {
flags = (unsigned int)lua_tointeger(L, 3);
} else if (lua_istable(L, 3)) {
lua_getfield(L, 3, "reuseaddr");
if (lua_toboolean(L, -1)) flags |= UV_UDP_REUSEADDR;
lua_pop(L, 1);
lua_getfield(L, 3, "reuseport");
if (lua_toboolean(L, -1)) flags |= UV_UDP_REUSEPORT;
lua_pop(L, 1);
} else {
return luaL_argerror(L, 3, "expected integer or table");
}
}

int ret = uv_udp_open_ex(handle, sock, flags);
return luv_result(L, ret);
}
#endif

static int luv_udp_bind(lua_State* L) {
uv_udp_t* handle = luv_check_udp(L, 1);
const char* host = luaL_checkstring(L, 2);
Expand Down
6 changes: 6 additions & 0 deletions tests/test-fs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,12 @@ return require('lib/tap')(function (test)
assert(stat.bavail>0)
end, "1.31.0")

test("fs.statfs frsize", function (print, p, expect, uv)
local stat = assert(uv.fs_statfs("."))
p(stat)
assert(stat.frsize ~= nil)
end, "1.52.0")

test("fs.statfs async", function (print, p, expect, uv)
assert(uv.fs_statfs(".", expect(function (err, stat)
assert(not err, err)
Expand Down
Loading