mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Fix deadlocks on some awaits
This commit is contained in:
@@ -41,21 +41,19 @@ impl crate::Controller for CtrlFanAndCPU {
|
||||
tokio::spawn(async move {
|
||||
while let Some(mode) = recv.recv().await {
|
||||
let mut config = config1.lock().await;
|
||||
if let Ok(mut lock) = gate1.try_lock() {
|
||||
lock.set_fan_mode(mode, &mut config)
|
||||
.unwrap_or_else(|err| warn!("{:?}", err));
|
||||
}
|
||||
let mut lock = gate1.lock().await;
|
||||
lock.set_fan_mode(mode, &mut config)
|
||||
.unwrap_or_else(|err| warn!("{:?}", err));
|
||||
}
|
||||
}),
|
||||
// need to watch file path
|
||||
tokio::spawn(async move {
|
||||
loop {
|
||||
if let Ok(mut lock) = gate2.try_lock() {
|
||||
let mut config = config.lock().await;
|
||||
let mut lock = gate2.lock().await;
|
||||
if let Ok(mut config) = config.try_lock() {
|
||||
lock.fan_mode_check_change(&mut config)
|
||||
.unwrap_or_else(|err| warn!("{:?}", err));
|
||||
}
|
||||
|
||||
tokio::time::delay_for(std::time::Duration::from_millis(500)).await;
|
||||
}
|
||||
}),
|
||||
|
||||
@@ -77,9 +77,10 @@ impl crate::Controller for CtrlKbdBacklight {
|
||||
tokio::spawn(async move {
|
||||
loop {
|
||||
let mut lock = gate2.lock().await;
|
||||
let mut config = config.lock().await;
|
||||
lock.let_bright_check_change(&mut config)
|
||||
.unwrap_or_else(|err| warn!("{:?}", err));
|
||||
if let Ok(mut config) = config.try_lock() {
|
||||
lock.let_bright_check_change(&mut config)
|
||||
.unwrap_or_else(|err| warn!("{:?}", err));
|
||||
}
|
||||
tokio::time::delay_for(std::time::Duration::from_millis(500)).await;
|
||||
}
|
||||
}),
|
||||
@@ -148,7 +149,7 @@ impl CtrlKbdBacklight {
|
||||
for device in enumerator.scan_devices()? {
|
||||
if let Some(parent) = device.parent_with_subsystem_devtype("usb", "usb_device")? {
|
||||
if parent.attribute_value("idProduct").unwrap() == id_product {
|
||||
// && device.parent().unwrap().sysnum().unwrap() == 3
|
||||
// && device.parent().unwrap().sysnum().unwrap() == 3
|
||||
if let Some(dev_node) = device.devnode() {
|
||||
info!("Using device at: {:?} for LED control", dev_node);
|
||||
return Ok(dev_node.to_string_lossy().to_string());
|
||||
|
||||
@@ -4,11 +4,15 @@ use daemon::{
|
||||
laptops::match_laptop,
|
||||
};
|
||||
|
||||
use dbus::{channel::Sender, nonblock::SyncConnection, tree::Signal};
|
||||
use dbus::{
|
||||
channel::Sender,
|
||||
nonblock::{Process, SyncConnection},
|
||||
tree::Signal,
|
||||
};
|
||||
use dbus_tokio::connection;
|
||||
|
||||
use asus_nb::{DBUS_IFACE, DBUS_NAME, DBUS_PATH};
|
||||
use daemon::Controller;
|
||||
use dbus_tokio::connection;
|
||||
use log::LevelFilter;
|
||||
use log::{error, info, warn};
|
||||
use std::error::Error;
|
||||
@@ -161,6 +165,7 @@ pub async fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
));
|
||||
}
|
||||
|
||||
connection.process_all();
|
||||
for handle in handles {
|
||||
handle.await?;
|
||||
}
|
||||
|
||||
@@ -18,4 +18,3 @@ impl fmt::Display for AuraError {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user