diff --git a/rsbinder-tools/src/bin/rsb_hub.rs b/rsbinder-tools/src/bin/rsb_hub.rs index 94d1cac..c10a7dc 100644 --- a/rsbinder-tools/src/bin/rsb_hub.rs +++ b/rsbinder-tools/src/bin/rsb_hub.rs @@ -246,7 +246,7 @@ fn main() -> std::result::Result<(), Box> { let _ = clap::Command::new("rsb_hub") .version(env!("CARGO_PKG_VERSION")) .author(env!("CARGO_PKG_AUTHORS")) - .about("Linux daemon that emulates functionality similar to Android's ServiceManager") + .about("A service manager for Binder IPC on Linux. Facilitates service registration, discovery, and management.") .get_matches(); env_logger::Builder::from_env(Env::default().default_filter_or("warn")).init(); diff --git a/rsbinder/src/ref_counter.rs b/rsbinder/src/ref_counter.rs index 9bcd7ba..dfcc6bd 100644 --- a/rsbinder/src/ref_counter.rs +++ b/rsbinder/src/ref_counter.rs @@ -69,10 +69,10 @@ impl RefCounter { pub fn dec(&self, f: impl FnOnce() -> Result<()>) -> Result<()> { let c = self.count.fetch_sub(1, Ordering::Relaxed); if c == 1 { - self.count.compare_exchange(0, INITIAL_STRONG_VALUE, - Ordering::Relaxed, Ordering::Relaxed) - .expect("Failed to exchange the reference count."); - f()?; + if self.count.compare_exchange(0, INITIAL_STRONG_VALUE, + Ordering::Relaxed, Ordering::Relaxed).is_ok() { + f()?; + } } Ok(()) } diff --git a/tests/src/test_client.rs b/tests/src/test_client.rs index fbd66e5..fab8fea 100644 --- a/tests/src/test_client.rs +++ b/tests/src/test_client.rs @@ -968,40 +968,40 @@ fn test_renamed_interface_old_as_old() { }); } -// #[test] -// fn test_renamed_interface_new_as_new() { -// test_renamed_interface(|_, new_name| { -// assert_eq!( -// ::descriptor(), -// "android.aidl.tests.IOldName" -// ); - -// let real_name = new_name.RealName(); -// assert_eq!(real_name.as_ref().map(String::as_str), Ok("NewName")); -// }); -// } +#[test] +fn test_renamed_interface_new_as_new() { + test_renamed_interface(|_, new_name| { + assert_eq!( + ::descriptor(), + "android.aidl.tests.IOldName" + ); -// #[test] -// fn test_renamed_interface_old_as_new() { -// test_renamed_interface(|old_name, _| { -// let new_name = old_name.as_binder().into_interface::(); -// assert!(new_name.is_ok()); - -// let real_name = new_name.unwrap().RealName(); -// assert_eq!(real_name.as_ref().map(String::as_str), Ok("OldName")); -// }); -// } + let real_name = new_name.RealName(); + assert_eq!(real_name.as_ref().map(String::as_str), Ok("NewName")); + }); +} -// #[test] -// fn test_renamed_interface_new_as_old() { -// test_renamed_interface(|_, new_name| { -// let old_name = new_name.as_binder().into_interface::(); -// assert!(old_name.is_ok()); - -// let real_name = old_name.unwrap().RealName(); -// assert_eq!(real_name.as_ref().map(String::as_str), Ok("NewName")); -// }); -// } +#[test] +fn test_renamed_interface_old_as_new() { + test_renamed_interface(|old_name, _| { + let new_name = old_name.as_binder().into_interface::(); + assert!(new_name.is_ok()); + + let real_name = new_name.unwrap().RealName(); + assert_eq!(real_name.as_ref().map(String::as_str), Ok("OldName")); + }); +} + +#[test] +fn test_renamed_interface_new_as_old() { + test_renamed_interface(|_, new_name| { + let old_name = new_name.as_binder().into_interface::(); + assert!(old_name.is_ok()); + + let real_name = old_name.unwrap().RealName(); + assert_eq!(real_name.as_ref().map(String::as_str), Ok("NewName")); + }); +} #[derive(Debug, Default)] struct Callback {