From 0115e3aaaeb5b09c79a5e0516e90054aada2beaf Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Mon, 3 Jul 2023 10:13:29 -0400 Subject: [PATCH] refactor: update launchpad --- Cargo.lock | 52 +++++++++++++++++++++++++++------------------------- src/main.rs | 33 ++++++--------------------------- 2 files changed, 33 insertions(+), 52 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1b91c46..54645d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -102,7 +102,7 @@ checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -124,13 +124,13 @@ checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae" [[package]] name = "async-trait" -version = "0.1.68" +version = "0.1.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" +checksum = "7b2d0f03b3640e3a630367e40c468cb7f309529c708ed1d88597047b0e7c6ef7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -259,7 +259,7 @@ dependencies = [ [[package]] name = "cosmic-notifications-util" version = "0.1.0" -source = "git+https://github.com/pop-os/cosmic-notifications#7e8dc5369f72a2515a4213e9084b1255cbc6c66a" +source = "git+https://github.com/pop-os/cosmic-notifications#5978b73af0adf79485b1ed13ec942ef8e7d123e0" dependencies = [ "bytemuck", "serde", @@ -356,7 +356,7 @@ checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -446,7 +446,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -559,16 +559,17 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "c0aa48fab2893d8a49caa94082ae8488f4e1050d73b367881dcd2198f4199fd8" [[package]] name = "launch-pad" version = "0.1.0" -source = "git+https://github.com/pop-os/launch-pad?branch=stdin-msg#a29643a7e22bff92848e4eeb9de665c1e9c08536" +source = "git+https://github.com/pop-os/launch-pad?branch=stdin-msg#8c3f83c09e4d5d7d62d95dbe0a4ef878a184d90b" dependencies = [ "log", + "nix 0.26.2", "rand", "slotmap", "thiserror", @@ -696,6 +697,7 @@ dependencies = [ "cfg-if", "libc", "memoffset 0.7.1", + "pin-utils", "static_assertions", ] @@ -777,9 +779,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" [[package]] name = "pin-utils" @@ -916,9 +918,9 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustix" -version = "0.37.21" +version = "0.37.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f25693a73057a1b4cb56179dd3c7ea21a7c6c5ee7d85781f5749b46f34b79c" +checksum = "8818fa822adcc98b18fedbb3632a6a33213c070556b5aa7c4c8cc21cff565c4c" dependencies = [ "bitflags", "errno", @@ -952,22 +954,22 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.164" +version = "1.0.165" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" +checksum = "c939f902bb7d0ccc5bce4f03297e161543c2dcb30914faf032c2bd0b7a0d48fc" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.164" +version = "1.0.165" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" +checksum = "6eaae920e25fffe4019b75ff65e7660e72091e59dd204cb5849bbd6a3fd343d7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -989,7 +991,7 @@ checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -1084,9 +1086,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.22" +version = "2.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2efbeae7acf4eabd6bcdcbd11c92f45231ddda7539edc7806bd1a04a03b24616" +checksum = "59fb7d6d8281a51045d62b8eb3a7d1ce347b76f312af50cd3dc0af39c87c1737" dependencies = [ "proc-macro2", "quote", @@ -1124,7 +1126,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -1165,7 +1167,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -1218,7 +1220,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] diff --git a/src/main.rs b/src/main.rs index bd4a1bc..8b359e8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,6 @@ mod service; mod systemd; use std::{ - ops::Deref, os::fd::AsRawFd, sync::{Arc, Mutex}, }; @@ -28,8 +27,6 @@ use tracing::{metadata::LevelFilter, Instrument}; use tracing_subscriber::{fmt, prelude::*, EnvFilter}; use zbus::ConnectionBuilder; -use crate::process::{mark_as_cloexec, mark_as_not_cloexec}; - #[tokio::main(flavor = "current_thread")] async fn main() -> Result<()> { color_eyre::install().wrap_err("failed to install color_eyre error handler")?; @@ -82,7 +79,6 @@ async fn main() -> Result<()> { )); let panel_notifications_fd_pre = Arc::new(Mutex::new(panel_notifications_fd)); - let panel_notifications_fd_post = panel_notifications_fd_pre.clone(); let span = info_span!(parent: None, "cosmic-panel"); let stdout_span = span.clone(); let stderr_span = span; @@ -90,19 +86,11 @@ async fn main() -> Result<()> { .start( Process::new() .with_executable("cosmic-panel") - .with_pre_start(move |_, _, _| { + // XXX this should be safe because cosmic-session runs on a single thread + .with_fds(move || { let panel_notifications_fd = panel_notifications_fd_pre.clone(); let fd = panel_notifications_fd.lock().unwrap(); - let fd = fd.deref(); - mark_as_not_cloexec(&fd) - .expect("Failed to mark panel notifications socket as not CLOEXEC"); - }) - .with_post_start(move |_, _, _| { - let panel_notifications_fd = panel_notifications_fd_post.clone(); - let fd = panel_notifications_fd.lock().unwrap(); - let fd = fd.deref(); - mark_as_cloexec(&fd) - .expect("Failed to mark panel notifications socket as CLOEXEC"); + vec![fd.as_raw_fd()] }) .with_on_stdout(move |_, _, line| { let stdout_span = stdout_span.clone(); @@ -132,25 +120,16 @@ async fn main() -> Result<()> { let stdout_span = span.clone(); let stderr_span = span; let daemon_notifications_fd_pre = Arc::new(Mutex::new(daemon_notifications_fd)); - let daemon_notifications_fd_post = daemon_notifications_fd_pre.clone(); process_manager .start( Process::new() .with_executable("cosmic-notifications") - .with_pre_start(move |_, _, _| { + // XXX this should be safe because cosmic-session runs on a single thread + .with_fds(move || { let daemon_notifications_fd = daemon_notifications_fd_pre.clone(); let fd = daemon_notifications_fd.lock().unwrap(); - let fd = fd.deref(); - mark_as_not_cloexec(&fd) - .expect("Failed to mark daemon notifications socket as not CLOEXEC"); - }) - .with_post_start(move |_, _, _| { - let daemon_notifications_fd = daemon_notifications_fd_post.clone(); - let fd = daemon_notifications_fd.lock().unwrap(); - let fd = fd.deref(); - mark_as_cloexec(&fd) - .expect("Failed to mark daemon notifications socket as CLOEXEC"); + vec![fd.as_raw_fd()] }) .with_on_stdout(move |_, _, line| { let stdout_span = stdout_span.clone();