summaryrefslogtreecommitdiffstats
path: root/src/app
diff options
context:
space:
mode:
authorClement Tsang <34804052+ClementTsang@users.noreply.github.com>2023-06-07 21:47:05 -0400
committerGitHub <noreply@github.com>2023-06-07 21:47:05 -0400
commit358bddf990e204f1de7fb20a133a14e1af2bbe43 (patch)
treee93852bf6df0c19f0902bdb074c94086684bfc9a /src/app
parent6dd4ea945b71c481c1b24f6810304d871cde476e (diff)
bug: when getting Linux temps, don't bail ASAP if they fail (#1186)
* bug: when getting Linux temps, don't bail ASAP if they fail This meant that if hwmon failed, it would never try and get temperatures from thermal or GPU. The same is true for thermal failing leading to GPU never running. * update docs
Diffstat (limited to 'src/app')
-rw-r--r--src/app/data_harvester/temperature/linux.rs18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/app/data_harvester/temperature/linux.rs b/src/app/data_harvester/temperature/linux.rs
index 8e5f7674..c3f250ec 100644
--- a/src/app/data_harvester/temperature/linux.rs
+++ b/src/app/data_harvester/temperature/linux.rs
@@ -11,8 +11,9 @@ use crate::app::{
};
/// Get temperature sensors from the linux sysfs interface `/sys/class/hwmon`.
-/// See [here](https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-hwmon) for
-/// details.
+///
+/// See [the Linux kernel documentation](https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-hwmon)
+/// for more details.
///
/// This method will return `0` as the temperature for devices, such as GPUs,
/// that support power management features and power themselves off.
@@ -191,8 +192,10 @@ fn get_from_hwmon(
}
/// Gets data from `/sys/class/thermal/thermal_zone*`. This should only be used if
-/// [`get_from_hwmon`] doesn't return anything. See
-/// [here](https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-thermal) for details.
+/// [`get_from_hwmon`] doesn't return anything.
+///
+/// See [the Linux kernel documentation](https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-thermal)
+/// for more details.
fn get_from_thermal_zone(
temp_type: &TemperatureType, filter: &Option<Filter>,
) -> Result<Vec<TempHarvest>> {
@@ -238,11 +241,12 @@ fn get_from_thermal_zone(
pub fn get_temperature_data(
temp_type: &TemperatureType, filter: &Option<Filter>,
) -> Result<Option<Vec<TempHarvest>>> {
- let mut temperature_vec: Vec<TempHarvest> = get_from_hwmon(temp_type, filter)?;
+ let mut temperature_vec: Vec<TempHarvest> =
+ get_from_hwmon(temp_type, filter).unwrap_or_default();
if temperature_vec.is_empty() {
- // If it's empty, fall back to checking `thermal_zone*`.
- temperature_vec = get_from_thermal_zone(temp_type, filter)?;
+ // If it's empty, try to fall back to checking `thermal_zone*`.
+ temperature_vec = get_from_thermal_zone(temp_type, filter).unwrap_or_default();
}
#[cfg(feature = "nvidia")]