Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
radicle: Only set file limits on Unix
Lorenz Leutgeb committed 9 months ago
commit 08b535d56794bd378a73e491147c934550ac2d45
parent e7fb5647ac0fe39e04c51e1e19ac030637aa0011
2 files changed +17 -4
modified crates/radicle/Cargo.toml
@@ -26,7 +26,6 @@ fast-glob = { version = "0.3.2" }
fastrand = { workspace = true }
git2 = { workspace = true, features = ["vendored-libgit2"] }
indexmap = { version = "2", features = ["serde"] }
-
libc = { workspace = true }
localtime = { workspace = true, features = ["serde"] }
log = { workspace = true, features = ["std"] }
multibase = { workspace = true }
@@ -46,6 +45,9 @@ tempfile = { workspace = true }
thiserror = { workspace = true }
unicode-normalization = { version = "0.1" }

+
[target.'cfg(unix)'.dependencies]
+
libc = { workspace = true }
+

[dev-dependencies]
emojis = "0.6"
jsonschema = { version = "0.30", default-features = false }
@@ -53,4 +55,4 @@ pretty_assertions = { workspace = true }
qcheck = { workspace = true }
qcheck-macros = { workspace = true }
radicle-cob = { workspace = true, features = ["stable-commit-ids"] }
-
radicle-crypto = { workspace = true, features = ["test"] }

\ No newline at end of file
+
radicle-crypto = { workspace = true, features = ["test"] }
modified crates/radicle/src/io.rs
@@ -1,14 +1,25 @@
-
use std::fmt;
use std::io;

+
#[cfg(unix)]
use libc::{getrlimit, rlim_t, rlimit, setrlimit, RLIMIT_NOFILE};

+
#[cfg(unix)]
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.
+
#[cfg(unix)]
pub fn set_file_limit<N>(n: N) -> io::Result<Int>
where
-
    N: Copy + fmt::Display,
+
    N: Copy + std::fmt::Display,
    Int: TryFrom<N>,
{
    let Ok(n) = Int::try_from(n) else {