Add hard fileno (#366)

* increase the fileno limit

This allows wstunnel to use fds>1024.
Otherwise heavy use can easily run out of file descriptors on connection
attempts.
While there will still be a limit, it is significantly higher (~500
times on my system) which provides enough headroom for connections to be
torn down and fds to be closed.
This commit is contained in:
Ongy 2024-11-08 19:51:56 +01:00 committed by GitHub
parent 820cb2232a
commit 05043954af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 1 deletions

11
Cargo.lock generated
View file

@ -765,6 +765,16 @@ dependencies = [
"utf-8", "utf-8",
] ]
[[package]]
name = "fdlimit"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e182f7dbc2ef73d9ef67351c5fbbea084729c48362d3ce9dd44c28e32e277fe5"
dependencies = [
"libc",
"thiserror",
]
[[package]] [[package]]
name = "filetime" name = "filetime"
version = "0.2.25" version = "0.2.25"
@ -3128,6 +3138,7 @@ dependencies = [
"crossterm", "crossterm",
"fast-socks5", "fast-socks5",
"fastwebsockets", "fastwebsockets",
"fdlimit",
"futures-util", "futures-util",
"hickory-resolver", "hickory-resolver",
"http-body-util", "http-body-util",

View file

@ -23,6 +23,8 @@ ppp = { version = "2.2.0", features = [] }
async-channel = { version = "2.3.1", features = [] } async-channel = { version = "2.3.1", features = [] }
arc-swap = { version = "1.7.1", features = [] } arc-swap = { version = "1.7.1", features = [] }
fdlimit = "0.3.0"
# For config file parsing # For config file parsing
regex = { version = "1.11.0", default-features = false, features = ["std", "perf"] } regex = { version = "1.11.0", default-features = false, features = ["std", "perf"] }
serde_regex = "1.1.0" serde_regex = "1.1.0"

View file

@ -19,7 +19,7 @@ use base64::Engine;
use clap::Parser; use clap::Parser;
use hyper::header::HOST; use hyper::header::HOST;
use hyper::http::{HeaderName, HeaderValue}; use hyper::http::{HeaderName, HeaderValue};
use log::debug; use log::{debug, warn};
use parking_lot::{Mutex, RwLock}; use parking_lot::{Mutex, RwLock};
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::fmt::Debug; use std::fmt::Debug;
@ -727,6 +727,9 @@ async fn main() -> anyhow::Result<()> {
} else { } else {
logger.init(); logger.init();
}; };
if let Err(err) = fdlimit::raise_fd_limit() {
warn!("Failed to set soft filelimit to hard file limit: {}", err)
}
match args.commands { match args.commands {
Commands::Client(args) => { Commands::Client(args) => {