rlimits: be safe if the nice value is bigger than the hard one

encoder
Tpt 3 years ago
parent cc4e3f8b0f
commit c815782631
  1. 3
      lib/src/storage/backend/rocksdb.rs

@ -9,6 +9,7 @@ use libc::{self, c_char, c_void, free};
use oxrocksdb_sys::*;
use rand::random;
use std::borrow::Borrow;
use std::cmp::min;
use std::collections::HashMap;
use std::env::temp_dir;
use std::error::Error;
@ -1134,7 +1135,7 @@ fn available_file_descriptors() -> io::Result<Option<u64>> {
rlim_max: 0,
};
if unsafe { libc::getrlimit(libc::RLIMIT_NOFILE, &mut rlimit) } == 0 {
Ok(Some(rlimit.rlim_cur))
Ok(Some(min(rlimit.rlim_cur, rlimit.rlim_max)))
} else {
Err(io::Error::last_os_error())
}

Loading…
Cancel
Save