Skip to content

Commit

Permalink
Use SeqCst ordering as we aren't sure how collectd is calling us
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbabcock committed Oct 6, 2023
1 parent 8d5112b commit e6a6849
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl Plugin for MyErrorPlugin {
}

fn read_values(&self) -> Result<(), Box<error::Error>> {
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"))?
Expand Down
2 changes: 1 addition & 1 deletion examples/myerror.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Plugin for MyErrorPlugin {
}

fn read_values(&self) -> Result<(), Box<dyn error::Error>> {
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())
Expand Down
4 changes: 2 additions & 2 deletions src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ fn register_all_plugins<T: PluginManager>(config: Option<&[ConfigItem<'_>]>) ->
}

pub fn plugin_init<T: PluginManager>(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::<T>(None)
} else {
0
Expand Down Expand Up @@ -262,7 +262,7 @@ pub unsafe fn plugin_complex_config<T: PluginManager>(
) -> 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;
}
Expand Down

0 comments on commit e6a6849

Please sign in to comment.