mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 02:48:03 +00:00
Do not panic if the fdlimit call to increase the file descriptor limit fails (#2155)
# Description Sometimes changing file descriptor limits is not allowed, but there is no need to crash the node if/when this happens. Since `fdlimit`'s author decided to use panics instead of returning `Result`, we need to catch it. # Checklist - [x] My PR includes a detailed description as outlined in the "Description" section above - [ ] My PR follows the [labeling requirements](CONTRIBUTING.md#Process) of this project (at minimum one label for `T` required) - [ ] I have made corresponding changes to the documentation (if applicable) - [ ] I have added tests that prove my fix is effective or that my feature works (if applicable) --------- Co-authored-by: Koute <koute@users.noreply.github.com>
This commit is contained in:
@@ -605,14 +605,25 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
|
||||
|
||||
logger.init()?;
|
||||
|
||||
if let Some(new_limit) = fdlimit::raise_fd_limit() {
|
||||
if new_limit < RECOMMENDED_OPEN_FILE_DESCRIPTOR_LIMIT {
|
||||
match fdlimit::raise_fd_limit() {
|
||||
Ok(fdlimit::Outcome::LimitRaised { to, .. }) =>
|
||||
if to < RECOMMENDED_OPEN_FILE_DESCRIPTOR_LIMIT {
|
||||
warn!(
|
||||
"Low open file descriptor limit configured for the process. \
|
||||
Current value: {:?}, recommended value: {:?}.",
|
||||
to, RECOMMENDED_OPEN_FILE_DESCRIPTOR_LIMIT,
|
||||
);
|
||||
},
|
||||
Ok(fdlimit::Outcome::Unsupported) => {
|
||||
// Unsupported platform (non-Linux)
|
||||
},
|
||||
Err(error) => {
|
||||
warn!(
|
||||
"Low open file descriptor limit configured for the process. \
|
||||
Current value: {:?}, recommended value: {:?}.",
|
||||
new_limit, RECOMMENDED_OPEN_FILE_DESCRIPTOR_LIMIT,
|
||||
"Failed to configure file descriptor limit for the process: \
|
||||
{}, recommended value: {:?}.",
|
||||
error, RECOMMENDED_OPEN_FILE_DESCRIPTOR_LIMIT,
|
||||
);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user