make network.find_free_port return nil if not found

This commit is contained in:
MihailRis 2025-11-15 16:52:58 +03:00
parent 3725aacbb1
commit 5edd7b2bb5

View File

@ -410,7 +410,11 @@ static int l_get_total_download(lua::State* L, network::Network& network) {
}
static int l_find_free_port(lua::State* L, network::Network& network) {
return lua::pushinteger(L, network.findFreePort());
int port = network.findFreePort();
if (port == -1) {
return 0;
}
return lua::pushinteger(L, port);
}
static int l_set_nodelay(lua::State* L, network::Network& network) {