From baa8f8235b9d1cef9328301e833c13777b34dc4f Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Fri, 24 Jun 2022 12:01:56 +0200 Subject: [PATCH] If we can't bump the file limit high enough, try as high as we can --- src/main.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index dde1a7c..42d696e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -531,7 +531,16 @@ fn set_limits(config: &Config) -> Result<(), Error> { .saturating_add(config.listen_addrs.len() as u32), ) .saturating_add(16); - Resource::NOFILE.set(nb_descriptors as _, nb_descriptors as _)?; + if let Err(_) = Resource::NOFILE.set(nb_descriptors as _, nb_descriptors as _) { + let (_soft, hard) = Resource::NOFILE.get()?; + if nb_descriptors as u64 > hard as u64 { + warn!( + "Unable to set the number of open files to {}. The hard limit is {}", + nb_descriptors, hard + ); + } + Resource::NOFILE.set(hard, hard)?; + } Ok(()) }