mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
fix: make the startup path more robust
This commit is contained in:
@@ -78,14 +78,19 @@ impl AsusArmouryAttribute {
|
||||
let sig = signal_ctxt.clone();
|
||||
tokio::spawn(async move {
|
||||
let mut buffer = [0; 32];
|
||||
watch
|
||||
.into_event_stream(&mut buffer)
|
||||
.unwrap()
|
||||
.for_each(|_| async {
|
||||
debug!("{} changed", name);
|
||||
ctrl.$fn_prop_changed(&sig).await.ok();
|
||||
})
|
||||
.await;
|
||||
if let Ok(mut stream) = watch.into_event_stream(&mut buffer) {
|
||||
stream
|
||||
.for_each(|_| async {
|
||||
debug!("{} changed", name);
|
||||
ctrl.$fn_prop_changed(&sig).await.ok();
|
||||
})
|
||||
.await;
|
||||
} else {
|
||||
info!(
|
||||
"inotify event stream failed for {} ({}). You can ignore this if unsupported",
|
||||
name, $attr_str
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
Err(e) => info!(
|
||||
@@ -387,13 +392,37 @@ pub async fn start_attributes_zbus(
|
||||
power.clone(),
|
||||
config.clone(),
|
||||
);
|
||||
attr.reload().await?;
|
||||
|
||||
if let Err(e) = attr.reload().await {
|
||||
error!(
|
||||
"Skipping attribute '{}' due to reload error: {e:?}",
|
||||
attr.attr.name()
|
||||
);
|
||||
// continue with others
|
||||
continue;
|
||||
}
|
||||
|
||||
let path = dbus_path_for_attr(attr.attr.name());
|
||||
let sig = zbus::object_server::SignalEmitter::new(conn, path)?;
|
||||
attr.watch_and_notify(sig).await?;
|
||||
match zbus::object_server::SignalEmitter::new(conn, path) {
|
||||
Ok(sig) => {
|
||||
if let Err(e) = attr.watch_and_notify(sig).await {
|
||||
error!(
|
||||
"Failed to start watcher for '{}': {e:?}",
|
||||
attr.attr.name()
|
||||
);
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to create SignalEmitter for '{}': {e:?}", attr.attr.name());
|
||||
}
|
||||
}
|
||||
|
||||
attr.move_to_zbus(conn).await?;
|
||||
if let Err(e) = attr.move_to_zbus(conn).await {
|
||||
error!(
|
||||
"Failed to register attribute '{}' on zbus: {e:?}",
|
||||
attr.attr.name()
|
||||
);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -62,7 +62,9 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
|
||||
// Start zbus server
|
||||
let mut server = Connection::system().await?;
|
||||
server.object_server().at("/", ObjectManager).await.unwrap();
|
||||
if let Err(e) = server.object_server().at("/", ObjectManager).await {
|
||||
error!("Failed to register ObjectManager at root '/': {e:?}");
|
||||
}
|
||||
|
||||
let config = Config::new().load();
|
||||
let cfg_path = config.file_path();
|
||||
@@ -72,14 +74,17 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
let platform = RogPlatform::new()?; // TODO: maybe needs async mutex?
|
||||
let power = AsusPower::new()?; // TODO: maybe needs async mutex?
|
||||
let attributes = FirmwareAttributes::new();
|
||||
start_attributes_zbus(
|
||||
if let Err(e) = start_attributes_zbus(
|
||||
&server,
|
||||
platform.clone(),
|
||||
power.clone(),
|
||||
attributes.clone(),
|
||||
config.clone(),
|
||||
)
|
||||
.await?;
|
||||
.await
|
||||
{
|
||||
error!("Failed to initialize firmware attributes over zbus: {e:?}");
|
||||
}
|
||||
|
||||
match CtrlFanCurveZbus::new() {
|
||||
Ok(ctrl) => {
|
||||
|
||||
Reference in New Issue
Block a user