Skip to content

Commit d36d5b6

Browse files
authored
Merge pull request #209 from mulimoen/bugfix/silence-errors
Call silence_errors for every thread
2 parents 50e3be1 + 36dc523 commit d36d5b6

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- Fixed a bug where `H5Pget_fapl_direct` was only included when HDF5 was compiled
2020
with feature `have-parallel` instead of `have-direct`.
2121
- Fixed a missing symbol when building `hdf5-src` with `libz-sys`.
22+
- Fixed a bug where errors were only silenced on the main thread.
2223

2324
## 0.8.1
2425

src/sync.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
use std::sync::atomic::{AtomicBool, Ordering};
2+
13
use lazy_static::lazy_static;
24
use parking_lot::ReentrantMutex;
35

6+
thread_local! {
7+
pub static SILENCED: AtomicBool = AtomicBool::new(false);
8+
}
9+
410
lazy_static! {
511
pub(crate) static ref LIBRARY_INIT: () = {
612
// No functions called here must try to create the LOCK,
@@ -29,6 +35,16 @@ where
2935
ReentrantMutex::new(())
3036
};
3137
}
38+
SILENCED.with(|silence| {
39+
let is_silenced = silence.load(Ordering::Acquire);
40+
if !is_silenced {
41+
let _guard = LOCK.lock();
42+
unsafe {
43+
crate::error::silence_errors_no_sync(true);
44+
}
45+
silence.store(true, Ordering::Release);
46+
}
47+
});
3248
let _guard = LOCK.lock();
3349
func()
3450
}

0 commit comments

Comments
 (0)