Skip to content

Commit

Permalink
bump nofile limit
Browse files Browse the repository at this point in the history
  • Loading branch information
zephyrchien committed Aug 28, 2022
1 parent f392cb7 commit 91671f0
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 13 deletions.
32 changes: 30 additions & 2 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion cmd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ license = "GPL-3.0"

[dependencies]
anyhow = "1"
realm_io = "0.3.2"
realm_io = "0.3.4"
realm_syscall = "0.1.6"
kaminari = { version = "0.9.2", features = ["ws"] }
tokio = { version = "1.9", features = ["rt", "net", "macros"] }

Expand Down
13 changes: 8 additions & 5 deletions cmd/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use kaminari::trick::Ref;
use kaminari::AsyncConnect;
use kaminari::nop::NopConnect;
use kaminari::ws::WsConnect;
#[cfg(any(feature="tls-rustls", feature="tls-openssl"))]
#[cfg(any(feature = "tls-rustls", feature = "tls-openssl"))]
use kaminari::tls::TlsConnect;

use kaminari_cmd::{Endpoint, parse_cmd, parse_env};
Expand All @@ -19,7 +19,7 @@ async fn main() -> Result<()> {
let (Endpoint { local, remote }, options) = parse_env().or_else(|_| parse_cmd())?;

let ws = opt::get_ws_conf(&options);
#[cfg(any(feature="tls-rustls", feature="tls-openssl"))]
#[cfg(any(feature = "tls-rustls", feature = "tls-openssl"))]
let tls = opt::get_tls_client_conf(&options);

eprintln!("listen: {}", &local);
Expand All @@ -29,13 +29,16 @@ async fn main() -> Result<()> {
eprintln!("ws: {}", ws)
}

#[cfg(any(feature="tls-rustls", feature="tls-openssl"))]
#[cfg(any(feature = "tls-rustls", feature = "tls-openssl"))]
if let Some(tls) = &tls {
eprintln!("tls: {}", &tls);
}

let lis = TcpListener::bind(local).await?;

#[cfg(all(unix, not(target_os = "android")))]
let _ = realm_syscall::bump_nofile_limit();

macro_rules! run {
($cc: expr) => {
println!("connect: {}", $cc.as_ref());
Expand Down Expand Up @@ -75,7 +78,7 @@ async fn main() -> Result<()> {
}
}

#[cfg(any(feature="tls-rustls", feature="tls-openssl"))]
#[cfg(any(feature = "tls-rustls", feature = "tls-openssl"))]
match (ws, tls) {
(None, None) => {
let client = NopConnect {};
Expand All @@ -95,7 +98,7 @@ async fn main() -> Result<()> {
}
};

#[cfg(not(any(feature="tls-rustls", feature="tls-openssl")))]
#[cfg(not(any(feature = "tls-rustls", feature = "tls-openssl")))]
if let Some(ws) = ws {
let client = WsConnect::new(NopConnect {}, ws);
run_ws_each!(client);
Expand Down
13 changes: 8 additions & 5 deletions cmd/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use kaminari::trick::Ref;
use kaminari::AsyncAccept;
use kaminari::nop::NopAccept;
use kaminari::ws::WsAccept;
#[cfg(any(feature="tls-rustls", feature="tls-openssl"))]
#[cfg(any(feature = "tls-rustls", feature = "tls-openssl"))]
use kaminari::tls::TlsAccept;

use kaminari_cmd::{Endpoint, parse_cmd, parse_env};
Expand All @@ -30,7 +30,7 @@ async fn main() -> Result<()> {

let ws = opt::get_ws_conf(&options);

#[cfg(any(feature="tls-rustls", feature="tls-openssl"))]
#[cfg(any(feature = "tls-rustls", feature = "tls-openssl"))]
let tls = opt::get_tls_server_conf(&options);

eprintln!("listen: {}", &local);
Expand All @@ -40,13 +40,16 @@ async fn main() -> Result<()> {
eprintln!("ws: {}", ws)
}

#[cfg(any(feature="tls-rustls", feature="tls-openssl"))]
#[cfg(any(feature = "tls-rustls", feature = "tls-openssl"))]
if let Some(tls) = &tls {
eprintln!("tls: {}", &tls);
}

let lis = TcpListener::bind(local).await?;

#[cfg(all(unix, not(target_os = "android")))]
let _ = realm_syscall::bump_nofile_limit();

macro_rules! run {
($ac: expr) => {
println!("accept: {}", $ac.as_ref());
Expand All @@ -64,7 +67,7 @@ async fn main() -> Result<()> {
};
}

#[cfg(any(feature="tls-rustls", feature="tls-openssl"))]
#[cfg(any(feature = "tls-rustls", feature = "tls-openssl"))]
match (ws, tls) {
(None, None) => {
let server = NopAccept {};
Expand All @@ -84,7 +87,7 @@ async fn main() -> Result<()> {
}
};

#[cfg(not(any(feature="tls-rustls", feature="tls-openssl")))]
#[cfg(not(any(feature = "tls-rustls", feature = "tls-openssl")))]
if let Some(ws) = ws {
let server = WsAccept::new(NopAccept {}, ws);
run!(Ref::new(&server));
Expand Down

0 comments on commit 91671f0

Please sign in to comment.