Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more checks on host_processor_info #1206

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/unix/apple/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,14 @@ pub(crate) fn update_cpu_usage<F: FnOnce(Arc<CpuData>, *mut i32) -> (f32, usize)
&mut cpu_info as *mut *mut i32,
&mut num_cpu_info as *mut u32,
) == libc::KERN_SUCCESS
&& num_cpu_info > 0
&& !cpu_info.is_null()
{
let (total_percentage, len) =
f(Arc::new(CpuData::new(cpu_info, num_cpu_info)), cpu_info);
total_cpu_usage = total_percentage / len as f32;
} else {
sysinfo_debug!("host_processor_info failed, not updating CPU ticks usage...");
}
global_cpu.inner.set_cpu_usage(total_cpu_usage);
}
Expand Down