From e6a68494174a459a045e4c7273dd200cc2e16b59 Mon Sep 17 00:00:00 2001 From: Nick Babcock Date: Thu, 5 Oct 2023 19:56:58 -0500 Subject: [PATCH] Use SeqCst ordering as we aren't sure how collectd is calling us --- CHANGELOG.md | 2 +- examples/myerror.rs | 2 +- src/internal.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e34fc6..514dc74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -133,7 +133,7 @@ impl Plugin for MyErrorPlugin { } fn read_values(&self) -> Result<(), Box> { - if self.state.fetch_xor(true, Ordering::Relaxed) { + if self.state.fetch_xor(true, Ordering::SeqCst) { panic!("Oh dear what is wrong!?") } else { Err(failure::err_msg("bailing"))? diff --git a/examples/myerror.rs b/examples/myerror.rs index ebcc73e..574fbd8 100644 --- a/examples/myerror.rs +++ b/examples/myerror.rs @@ -41,7 +41,7 @@ impl Plugin for MyErrorPlugin { } fn read_values(&self) -> Result<(), Box> { - if self.state.fetch_xor(true, Ordering::Relaxed) { + if self.state.fetch_xor(true, Ordering::SeqCst) { panic!("Oh dear what is wrong!?") } else { Err(failure::err_msg("bailing").into()) diff --git a/src/internal.rs b/src/internal.rs index c3ec6b0..19f2b3d 100644 --- a/src/internal.rs +++ b/src/internal.rs @@ -214,7 +214,7 @@ fn register_all_plugins(config: Option<&[ConfigItem<'_>]>) -> } pub fn plugin_init(config_seen: &AtomicBool) -> c_int { - let mut result = if !config_seen.swap(true, Ordering::Relaxed) { + let mut result = if !config_seen.swap(true, Ordering::SeqCst) { register_all_plugins::(None) } else { 0 @@ -262,7 +262,7 @@ pub unsafe fn plugin_complex_config( ) -> c_int { // If we've already seen the config, let's error out as one shouldn't use multiple // sections of configuration (group them under nodes like write_graphite) - if config_seen.swap(true, Ordering::Relaxed) { + if config_seen.swap(true, Ordering::SeqCst) { log_err("config", &FfiError::MultipleConfig); return -1; }