Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove File Descriptor init on Windows #344

Closed
wants to merge 2 commits into from
Closed
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
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions kaspad/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ kaspa-utxoindex.workspace = true
kaspa-wrpc-server.workspace = true

async-channel.workspace = true
cfg-if.workspace = true
clap.workspace = true
dhat = { workspace = true, optional = true }
dirs.workspace = true
Expand Down
32 changes: 17 additions & 15 deletions kaspad/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ use std::sync::Arc;

use kaspa_core::{info, signals::Signals};
use kaspa_utils::fd_budget;
use kaspad_lib::{
args::parse_args,
daemon::{create_core, DESIRED_DAEMON_SOFT_FD_LIMIT, MINIMUM_DAEMON_SOFT_FD_LIMIT},
};
use kaspad_lib::{args::parse_args, daemon::create_core};

#[cfg(feature = "heap")]
#[global_allocator]
Expand All @@ -21,19 +18,24 @@ pub fn main() {

let args = parse_args();

match fd_budget::try_set_fd_limit(DESIRED_DAEMON_SOFT_FD_LIMIT) {
Ok(limit) => {
if limit < MINIMUM_DAEMON_SOFT_FD_LIMIT {
println!("Current OS file descriptor limit (soft FD limit) is set to {limit}");
println!("The kaspad node requires a setting of at least {DESIRED_DAEMON_SOFT_FD_LIMIT} to operate properly.");
println!("Please increase the limits using the following command:");
println!("ulimit -n {DESIRED_DAEMON_SOFT_FD_LIMIT}");
cfg_if::cfg_if! {
if #[cfg(any(target_os = "macos", target_os = "linux"))] {
use kaspad_lib::daemon::{DESIRED_DAEMON_SOFT_FD_LIMIT, MINIMUM_DAEMON_SOFT_FD_LIMIT};
match fd_budget::try_set_fd_limit(DESIRED_DAEMON_SOFT_FD_LIMIT) {
Ok(limit) => {
if limit < MINIMUM_DAEMON_SOFT_FD_LIMIT {
println!("Current OS file descriptor limit (soft FD limit) is set to {limit}");
println!("The kaspad node requires a setting of at least {DESIRED_DAEMON_SOFT_FD_LIMIT} to operate properly.");
println!("Please increase the limits using the following command:");
println!("ulimit -n {DESIRED_DAEMON_SOFT_FD_LIMIT}");
}
}
Err(err) => {
println!("Unable to initialize the necessary OS file descriptor limit (soft FD limit) to: {}", err);
println!("The kaspad node requires a setting of at least {DESIRED_DAEMON_SOFT_FD_LIMIT} to operate properly.");
}
}
}
Err(err) => {
println!("Unable to initialize the necessary OS file descriptor limit (soft FD limit) to: {}", err);
println!("The kaspad node requires a setting of at least {DESIRED_DAEMON_SOFT_FD_LIMIT} to operate properly.");
}
}

let fd_total_budget = fd_budget::limit() - args.rpc_max_clients as i32 - args.inbound_limit as i32 - args.outbound_target as i32;
Expand Down