File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -63,26 +63,24 @@ fn get_rng_fd() -> Result<libc::c_int, Error> {
63
63
}
64
64
val => return Ok ( val as libc:: c_int ) ,
65
65
}
66
- let res = FD . compare_exchange_weak (
66
+
67
+ let xch_res = FD . compare_exchange_weak (
67
68
FD_UNINIT ,
68
69
FD_ONGOING_INIT ,
69
70
Ordering :: AcqRel ,
70
71
Ordering :: Relaxed ,
71
72
) ;
72
- if res . is_err ( ) {
73
+ if xch_res . is_err ( ) {
73
74
continue ;
74
75
}
75
76
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
- }
77
+ let res = open_fd ( ) ;
78
+ let val = match res {
79
+ Ok ( fd) => fd as usize ,
80
+ Err ( _) => FD_UNINIT ,
85
81
} ;
82
+ FD . store ( val, Ordering :: Release ) ;
83
+ return res;
86
84
}
87
85
}
88
86
You can’t perform that action at this time.
0 commit comments