Replace `Arc` with `&'static`

pull/1043/head
Tamir Duberstein 4 months ago
parent 0e867572ff
commit e992c280cb

@ -8,7 +8,7 @@ use std::{
mem, mem,
os::{fd::AsFd as _, raw::c_char, unix::ffi::OsStrExt}, os::{fd::AsFd as _, raw::c_char, unix::ffi::OsStrExt},
path::{Path, PathBuf}, path::{Path, PathBuf},
sync::{Arc, LazyLock}, sync::LazyLock,
}; };
use libc::pid_t; use libc::pid_t;
@ -29,8 +29,8 @@ use crate::{
const LD_SO_CACHE_FILE: &str = "/etc/ld.so.cache"; const LD_SO_CACHE_FILE: &str = "/etc/ld.so.cache";
static LD_SO_CACHE: LazyLock<Result<LdSoCache, Arc<io::Error>>> = static LD_SO_CACHE: LazyLock<Result<LdSoCache, io::Error>> =
LazyLock::new(|| LdSoCache::load(LD_SO_CACHE_FILE).map_err(Arc::new)); LazyLock::new(|| LdSoCache::load(LD_SO_CACHE_FILE));
const LD_SO_CACHE_HEADER_OLD: &str = "ld.so-1.7.0\0"; const LD_SO_CACHE_HEADER_OLD: &str = "ld.so-1.7.0\0";
const LD_SO_CACHE_HEADER_NEW: &str = "glibc-ld.so.cache1.1"; const LD_SO_CACHE_HEADER_NEW: &str = "glibc-ld.so.cache1.1";
@ -140,9 +140,7 @@ fn resolve_attach_path(target: &Path, pid: Option<pid_t>) -> Result<Cow<'_, Path
.or_else(|| { .or_else(|| {
LD_SO_CACHE LD_SO_CACHE
.as_ref() .as_ref()
.map_err(|error| UProbeError::InvalidLdSoCache { .map_err(|io_error| UProbeError::InvalidLdSoCache { io_error })
io_error: error.clone(),
})
.map(|cache| cache.resolve(target).map(Cow::Borrowed)) .map(|cache| cache.resolve(target).map(Cow::Borrowed))
.transpose() .transpose()
}) })
@ -215,7 +213,7 @@ pub enum UProbeError {
InvalidLdSoCache { InvalidLdSoCache {
/// the original [`io::Error`] /// the original [`io::Error`]
#[source] #[source]
io_error: Arc<io::Error>, io_error: &'static io::Error,
}, },
/// The target program could not be found. /// The target program could not be found.

@ -6067,7 +6067,7 @@ pub aya::programs::uprobe::UProbeError::FileError
pub aya::programs::uprobe::UProbeError::FileError::filename: std::path::PathBuf pub aya::programs::uprobe::UProbeError::FileError::filename: std::path::PathBuf
pub aya::programs::uprobe::UProbeError::FileError::io_error: std::io::error::Error pub aya::programs::uprobe::UProbeError::FileError::io_error: std::io::error::Error
pub aya::programs::uprobe::UProbeError::InvalidLdSoCache pub aya::programs::uprobe::UProbeError::InvalidLdSoCache
pub aya::programs::uprobe::UProbeError::InvalidLdSoCache::io_error: alloc::sync::Arc<std::io::error::Error> pub aya::programs::uprobe::UProbeError::InvalidLdSoCache::io_error: &'static std::io::error::Error
pub aya::programs::uprobe::UProbeError::InvalidTarget pub aya::programs::uprobe::UProbeError::InvalidTarget
pub aya::programs::uprobe::UProbeError::InvalidTarget::path: std::path::PathBuf pub aya::programs::uprobe::UProbeError::InvalidTarget::path: std::path::PathBuf
pub aya::programs::uprobe::UProbeError::SymbolError pub aya::programs::uprobe::UProbeError::SymbolError
@ -7343,7 +7343,7 @@ pub aya::programs::UProbeError::FileError
pub aya::programs::UProbeError::FileError::filename: std::path::PathBuf pub aya::programs::UProbeError::FileError::filename: std::path::PathBuf
pub aya::programs::UProbeError::FileError::io_error: std::io::error::Error pub aya::programs::UProbeError::FileError::io_error: std::io::error::Error
pub aya::programs::UProbeError::InvalidLdSoCache pub aya::programs::UProbeError::InvalidLdSoCache
pub aya::programs::UProbeError::InvalidLdSoCache::io_error: alloc::sync::Arc<std::io::error::Error> pub aya::programs::UProbeError::InvalidLdSoCache::io_error: &'static std::io::error::Error
pub aya::programs::UProbeError::InvalidTarget pub aya::programs::UProbeError::InvalidTarget
pub aya::programs::UProbeError::InvalidTarget::path: std::path::PathBuf pub aya::programs::UProbeError::InvalidTarget::path: std::path::PathBuf
pub aya::programs::UProbeError::SymbolError pub aya::programs::UProbeError::SymbolError

Loading…
Cancel
Save