File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ const COUNTER_OFFSET: usize = PROCESS_ID_OFFSET + PROCESS_ID_SIZE;
24
24
const MAX_U24 : usize = 0xFFFFFF ;
25
25
26
26
static OID_COUNTER : AtomicUsize = ATOMIC_USIZE_INIT ;
27
- static mut MACHINE_BYTES : [ u8 ; 3 ] = [ 0 ; 3 ] ;
27
+ static mut MACHINE_BYTES : Option < [ u8 ; 3 ] > = None ;
28
28
29
29
extern {
30
30
fn gethostname ( name : * mut libc:: c_char , size : libc:: size_t ) -> libc:: c_int ;
@@ -191,8 +191,8 @@ impl ObjectId {
191
191
// Since the generated machine id is not variable, arising race conditions
192
192
// will have the same MACHINE_BYTES result.
193
193
unsafe {
194
- if MACHINE_BYTES [ 0 ] != 0 || MACHINE_BYTES [ 1 ] != 0 || MACHINE_BYTES [ 2 ] != 0 {
195
- return Ok ( MACHINE_BYTES ) ;
194
+ if let Some ( bytes ) = MACHINE_BYTES . as_ref ( ) {
195
+ return Ok ( bytes . clone ( ) ) ;
196
196
}
197
197
}
198
198
@@ -224,7 +224,7 @@ impl ObjectId {
224
224
}
225
225
}
226
226
227
- unsafe { MACHINE_BYTES = vec } ;
227
+ unsafe { MACHINE_BYTES = Some ( vec) } ;
228
228
Ok ( vec)
229
229
}
230
230
You can’t perform that action at this time.
0 commit comments