mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 18:25:30 +00:00
udp: Config.socket_workers: make value 0 auto-use available vCPUs
This commit is contained in:
parent
f4ef9fcfc9
commit
14c973f72f
2 changed files with 9 additions and 3 deletions
|
|
@ -3,7 +3,7 @@ pub mod config;
|
|||
pub mod swarm;
|
||||
pub mod workers;
|
||||
|
||||
use std::thread::{sleep, Builder, JoinHandle};
|
||||
use std::thread::{available_parallelism, sleep, Builder, JoinHandle};
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::Context;
|
||||
|
|
@ -22,9 +22,13 @@ use workers::socket::ConnectionValidator;
|
|||
pub const APP_NAME: &str = "aquatic_udp: UDP BitTorrent tracker";
|
||||
pub const APP_VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
pub fn run(config: Config) -> ::anyhow::Result<()> {
|
||||
pub fn run(mut config: Config) -> ::anyhow::Result<()> {
|
||||
let mut signals = Signals::new([SIGUSR1])?;
|
||||
|
||||
if config.socket_workers == 0 {
|
||||
config.socket_workers = available_parallelism().map(Into::into).unwrap_or(1);
|
||||
};
|
||||
|
||||
let state = State::default();
|
||||
let statistics = Statistics::new(&config);
|
||||
let connection_validator = ConnectionValidator::new(&config)?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue