We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ee6e835 commit d213562Copy full SHA for d213562
src/use_file.rs
@@ -63,26 +63,24 @@ fn get_rng_fd() -> Result<libc::c_int, Error> {
63
}
64
val => return Ok(val as libc::c_int),
65
66
- let res = FD.compare_exchange_weak(
+
67
+ let xch_res = FD.compare_exchange_weak(
68
FD_UNINIT,
69
FD_ONGOING_INIT,
70
Ordering::AcqRel,
71
Ordering::Relaxed,
72
);
- if res.is_err() {
73
+ if xch_res.is_err() {
74
continue;
75
76
- return match open_fd() {
77
- Ok(fd) => {
78
- FD.store(fd as usize, Ordering::Release);
79
- Ok(fd)
80
- }
81
- Err(err) => {
82
- FD.store(FD_UNINIT, Ordering::Release);
83
- Err(err)
84
+ let res = open_fd();
+ let val = match res {
+ Ok(fd) => fd as usize,
+ Err(_) => FD_UNINIT,
85
};
+ FD.store(val, Ordering::Release);
+ return res;
86
87
88
0 commit comments