From 147d5549b4adbefb8d0c82ca1bacf47506ea6062 Mon Sep 17 00:00:00 2001 From: MasterPtato Date: Mon, 26 May 2025 19:45:01 +0000 Subject: [PATCH] fix: fix client leaked pipes --- Cargo.toml | 2 +- packages/common/logs/src/lib.rs | 14 +++++----- .../edge/infra/client/manager/src/runner.rs | 2 +- packages/edge/services/pegboard/Cargo.toml | 4 +-- packages/toolchain/cli/Cargo.toml | 26 +++++++++---------- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 740a7c29c4..297de2cfdc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ version = "1.44.0" features = ["full","tracing"] [workspace.dependencies.nix] -version = "0.27" +version = "0.30" default-features = false features = ["fs","user","signal"] diff --git a/packages/common/logs/src/lib.rs b/packages/common/logs/src/lib.rs index eb4ef0d67a..809a9e3357 100644 --- a/packages/common/logs/src/lib.rs +++ b/packages/common/logs/src/lib.rs @@ -1,4 +1,4 @@ -use std::{os::fd::AsRawFd, path::PathBuf}; +use std::{os::fd::AsFd, path::PathBuf}; use anyhow::*; use chrono::{Datelike, Duration, TimeDelta, TimeZone, Utc}; @@ -80,10 +80,10 @@ impl Logs { .append(true) .open(path) .await?; - let log_fd = log_file.as_raw_fd(); + let log_fd = log_file.as_fd(); - nix::unistd::dup2(log_fd, nix::libc::STDOUT_FILENO)?; - nix::unistd::dup2(log_fd, nix::libc::STDERR_FILENO)?; + nix::unistd::dup2_stdout(log_fd)?; + nix::unistd::dup2_stderr(log_fd)?; self.prune().await } @@ -164,10 +164,10 @@ impl Logs { .create(true) .append(true) .open(path)?; - let log_fd = log_file.as_raw_fd(); + let log_fd = log_file.as_fd(); - nix::unistd::dup2(log_fd, nix::libc::STDOUT_FILENO)?; - nix::unistd::dup2(log_fd, nix::libc::STDERR_FILENO)?; + nix::unistd::dup2_stdout(log_fd)?; + nix::unistd::dup2_stderr(log_fd)?; self.prune_sync() } diff --git a/packages/edge/infra/client/manager/src/runner.rs b/packages/edge/infra/client/manager/src/runner.rs index 9ce2128dcd..6d1c09b2ad 100644 --- a/packages/edge/infra/client/manager/src/runner.rs +++ b/packages/edge/infra/client/manager/src/runner.rs @@ -185,7 +185,7 @@ impl Handle { // Prepare the arguments for the runner let runner_args = vec![working_path.to_str().context("bad path")?]; - // TODO: Do pipes have to be manually deleted here? + // NOTE: Pipes are automatically closed on drop // Pipe communication between processes let (pipe_read, pipe_write) = pipe()?; diff --git a/packages/edge/services/pegboard/Cargo.toml b/packages/edge/services/pegboard/Cargo.toml index 76fc3a670c..2e9036ef87 100644 --- a/packages/edge/services/pegboard/Cargo.toml +++ b/packages/edge/services/pegboard/Cargo.toml @@ -18,8 +18,9 @@ fdb-util = { workspace = true, optional = true } foundationdb = { workspace = true, optional = true } heck = "0.3" lazy_static = "1.4" -nix = { version = "0.27", default-features = false, features = ["user", "signal"], optional = true } +nix = { workspace = true, optional = true } rand = "0.8" +regex = "1.10.3" reqwest = { version = "0.12", features = ["json"] } rivet-api.workspace = true rivet-config.workspace = true @@ -35,7 +36,6 @@ serde_urlencoded = "0.7.0" strum = { version = "0.24", features = ["derive"] } thiserror = "1.0" uuid = "1.11.0" -regex = "1.10.3" build.workspace = true cluster.workspace = true diff --git a/packages/toolchain/cli/Cargo.toml b/packages/toolchain/cli/Cargo.toml index 0bbb4ca0bc..1b27f05d9b 100644 --- a/packages/toolchain/cli/Cargo.toml +++ b/packages/toolchain/cli/Cargo.toml @@ -14,26 +14,26 @@ path = "src/main.rs" # sentry = [] [dependencies] -clap = { version = "4.5.9", features = ["derive"] } -toolchain = { path = "../toolchain", package = "rivet-toolchain" } -tokio.workspace = true -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0.120" anyhow = "1.0" -uuid = { version = "1.11.0", features = ["v4"] } -url = { version = "2.5.3", features = ["serde"] } +async-posthog.workspace = true base64 = "0.22.1" -kv-str.workspace = true +clap = { version = "4.5.9", features = ["derive"] } +ctrlc = "3.4.5" +deno-embed.workspace = true inquire = "0.7.5" -webbrowser = "1.0.2" +kv-str.workspace = true # sentry = { version = "0.37.0", default-features = false, features = ["anyhow", "backtrace", "contexts", "debug-images", "panic", "reqwest", "rustls"] } +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0.120" sysinfo = "0.32.0" -ctrlc = "3.4.5" -async-posthog.workspace = true -deno-embed.workspace = true +tokio.workspace = true +toolchain = { path = "../toolchain", package = "rivet-toolchain" } +url = { version = "2.5.3", features = ["serde"] } +uuid = { version = "1.11.0", features = ["v4"] } +webbrowser = "1.0.2" [target.'cfg(unix)'.dependencies] -nix = { version = "0.27", default-features = false, features = ["user", "signal"] } +nix.workspace = true [build-dependencies] anyhow = "1.0"