Merge pull request #35 from jokeyrhyme/tokio-mutex-and-other-clippy-warnings
fix: use tokio Mutex and clear other clippy warnings
This commit is contained in:
commit
662ebce1b8
2 changed files with 11 additions and 14 deletions
13
src/main.rs
13
src/main.rs
|
|
@ -8,10 +8,7 @@ mod process;
|
||||||
mod service;
|
mod service;
|
||||||
mod systemd;
|
mod systemd;
|
||||||
|
|
||||||
use std::{
|
use std::{os::fd::AsRawFd, sync::Arc};
|
||||||
os::fd::AsRawFd,
|
|
||||||
sync::{Arc, Mutex},
|
|
||||||
};
|
|
||||||
|
|
||||||
use async_signals::Signals;
|
use async_signals::Signals;
|
||||||
use color_eyre::{eyre::WrapErr, Result};
|
use color_eyre::{eyre::WrapErr, Result};
|
||||||
|
|
@ -24,7 +21,7 @@ use tokio::{
|
||||||
net::UnixStream,
|
net::UnixStream,
|
||||||
sync::{
|
sync::{
|
||||||
mpsc::{self, Receiver, Sender},
|
mpsc::{self, Receiver, Sender},
|
||||||
oneshot,
|
oneshot, Mutex,
|
||||||
},
|
},
|
||||||
time::{sleep, Duration},
|
time::{sleep, Duration},
|
||||||
};
|
};
|
||||||
|
|
@ -149,7 +146,7 @@ async fn start(
|
||||||
let notifications_span = info_span!(parent: None, "cosmic-notifications");
|
let notifications_span = info_span!(parent: None, "cosmic-notifications");
|
||||||
let panel_span = info_span!(parent: None, "cosmic-panel");
|
let panel_span = info_span!(parent: None, "cosmic-panel");
|
||||||
|
|
||||||
let mut guard = notif_key.lock().unwrap();
|
let mut guard = notif_key.lock().await;
|
||||||
*guard = Some(
|
*guard = Some(
|
||||||
process_manager
|
process_manager
|
||||||
.start(notifications_process(
|
.start(notifications_process(
|
||||||
|
|
@ -169,7 +166,7 @@ async fn start(
|
||||||
);
|
);
|
||||||
drop(guard);
|
drop(guard);
|
||||||
|
|
||||||
let mut guard = panel_key.lock().unwrap();
|
let mut guard = panel_key.lock().await;
|
||||||
*guard = Some(
|
*guard = Some(
|
||||||
process_manager
|
process_manager
|
||||||
.start(notifications_process(
|
.start(notifications_process(
|
||||||
|
|
@ -343,5 +340,5 @@ async fn start_component(
|
||||||
.with_fds(move || vec![fd]),
|
.with_fds(move || vec![fd]),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.expect(&format!("failed to start {}", cmd));
|
.unwrap_or_else(|_| panic!("failed to start {}", cmd));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ use launch_pad::ProcessKey;
|
||||||
use rustix::fd::AsRawFd;
|
use rustix::fd::AsRawFd;
|
||||||
use std::os::fd::OwnedFd;
|
use std::os::fd::OwnedFd;
|
||||||
use std::os::unix::net::UnixStream;
|
use std::os::unix::net::UnixStream;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::Arc;
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::{mpsc, Mutex};
|
||||||
use tracing::Instrument;
|
use tracing::Instrument;
|
||||||
|
|
||||||
use crate::comp::create_privileged_socket;
|
use crate::comp::create_privileged_socket;
|
||||||
|
|
@ -76,7 +76,7 @@ pub fn notifications_process(
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.find(|(k, _v)| k == PANEL_NOTIFICATIONS_FD || k == DAEMON_NOTIFICATIONS_FD)
|
.find(|(k, _v)| k == PANEL_NOTIFICATIONS_FD || k == DAEMON_NOTIFICATIONS_FD)
|
||||||
{
|
{
|
||||||
*v = format!("{}", my_fd.as_raw_fd().to_string());
|
*v = my_fd.as_raw_fd().to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut their_env_vars = restart_env_vars.clone();
|
let mut their_env_vars = restart_env_vars.clone();
|
||||||
|
|
@ -84,7 +84,7 @@ pub fn notifications_process(
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.find(|(k, _v)| k == PANEL_NOTIFICATIONS_FD || k == DAEMON_NOTIFICATIONS_FD)
|
.find(|(k, _v)| k == PANEL_NOTIFICATIONS_FD || k == DAEMON_NOTIFICATIONS_FD)
|
||||||
{
|
{
|
||||||
*v = format!("{}", their_fd.as_raw_fd().to_string());
|
*v = their_fd.as_raw_fd().to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
let new_process = notifications_process(
|
let new_process = notifications_process(
|
||||||
|
|
@ -122,14 +122,14 @@ pub fn notifications_process(
|
||||||
error!(?why, "Failed to update fds");
|
error!(?why, "Failed to update fds");
|
||||||
}
|
}
|
||||||
|
|
||||||
let Some(old) = restart_key.lock().unwrap().clone() else {
|
let Some(old) = *restart_key.lock().await else {
|
||||||
error!("Couldn't stop previous invocation of {}", cmd);
|
error!("Couldn't stop previous invocation of {}", cmd);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
_ = pman.stop_process(old).await;
|
_ = pman.stop_process(old).await;
|
||||||
|
|
||||||
if let Ok(new) = pman.start(new_process).await {
|
if let Ok(new) = pman.start(new_process).await {
|
||||||
let mut guard = restart_key.lock().unwrap();
|
let mut guard = restart_key.lock().await;
|
||||||
*guard = Some(new);
|
*guard = Some(new);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue