radicle: Only set file limits on Unix
This commit is contained in:
parent
e7fb5647ac
commit
08b535d567
|
|
@ -26,7 +26,6 @@ fast-glob = { version = "0.3.2" }
|
||||||
fastrand = { workspace = true }
|
fastrand = { workspace = true }
|
||||||
git2 = { workspace = true, features = ["vendored-libgit2"] }
|
git2 = { workspace = true, features = ["vendored-libgit2"] }
|
||||||
indexmap = { version = "2", features = ["serde"] }
|
indexmap = { version = "2", features = ["serde"] }
|
||||||
libc = { workspace = true }
|
|
||||||
localtime = { workspace = true, features = ["serde"] }
|
localtime = { workspace = true, features = ["serde"] }
|
||||||
log = { workspace = true, features = ["std"] }
|
log = { workspace = true, features = ["std"] }
|
||||||
multibase = { workspace = true }
|
multibase = { workspace = true }
|
||||||
|
|
@ -46,6 +45,9 @@ tempfile = { workspace = true }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
unicode-normalization = { version = "0.1" }
|
unicode-normalization = { version = "0.1" }
|
||||||
|
|
||||||
|
[target.'cfg(unix)'.dependencies]
|
||||||
|
libc = { workspace = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
emojis = "0.6"
|
emojis = "0.6"
|
||||||
jsonschema = { version = "0.30", default-features = false }
|
jsonschema = { version = "0.30", default-features = false }
|
||||||
|
|
@ -53,4 +55,4 @@ pretty_assertions = { workspace = true }
|
||||||
qcheck = { workspace = true }
|
qcheck = { workspace = true }
|
||||||
qcheck-macros = { workspace = true }
|
qcheck-macros = { workspace = true }
|
||||||
radicle-cob = { workspace = true, features = ["stable-commit-ids"] }
|
radicle-cob = { workspace = true, features = ["stable-commit-ids"] }
|
||||||
radicle-crypto = { workspace = true, features = ["test"] }
|
radicle-crypto = { workspace = true, features = ["test"] }
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,25 @@
|
||||||
use std::fmt;
|
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
use libc::{getrlimit, rlim_t, rlimit, setrlimit, RLIMIT_NOFILE};
|
use libc::{getrlimit, rlim_t, rlimit, setrlimit, RLIMIT_NOFILE};
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
type Int = rlim_t;
|
type Int = rlim_t;
|
||||||
|
|
||||||
|
#[cfg(not(unix))]
|
||||||
|
#[inline]
|
||||||
|
pub fn set_file_limit<T>(_: T) -> io::Result<()> {
|
||||||
|
Err(io::Error::new(
|
||||||
|
io::ErrorKind::Unsupported,
|
||||||
|
"setting file limits is not supported on this platform",
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
/// Sets the open file limit to the given value, or the maximum allowed value.
|
/// Sets the open file limit to the given value, or the maximum allowed value.
|
||||||
|
#[cfg(unix)]
|
||||||
pub fn set_file_limit<N>(n: N) -> io::Result<Int>
|
pub fn set_file_limit<N>(n: N) -> io::Result<Int>
|
||||||
where
|
where
|
||||||
N: Copy + fmt::Display,
|
N: Copy + std::fmt::Display,
|
||||||
Int: TryFrom<N>,
|
Int: TryFrom<N>,
|
||||||
{
|
{
|
||||||
let Ok(n) = Int::try_from(n) else {
|
let Ok(n) = Int::try_from(n) else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue