File tree 3 files changed +12
-9
lines changed
3 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -64,10 +64,10 @@ pub unsafe fn init(argc: isize, argv: *const *const u8) {
64
64
args:: init ( argc, argv) ;
65
65
66
66
unsafe fn sanitize_standard_fds ( ) {
67
+ #[ cfg( not( miri) ) ]
68
+ // The standard fds are always available in Miri.
67
69
cfg_if:: cfg_if! {
68
70
if #[ cfg( not( any(
69
- // The standard fds are always available in Miri.
70
- miri,
71
71
target_os = "emscripten" ,
72
72
target_os = "fuchsia" ,
73
73
target_os = "vxworks" ,
Original file line number Diff line number Diff line change @@ -26,12 +26,12 @@ pub mod netc {
26
26
27
27
pub struct Socket ( c:: SOCKET ) ;
28
28
29
+ static INIT : Once = Once :: new ( ) ;
30
+
29
31
/// Checks whether the Windows socket interface has been started already, and
30
32
/// if not, starts it.
31
33
pub fn init ( ) {
32
- static START : Once = Once :: new ( ) ;
33
-
34
- START . call_once ( || unsafe {
34
+ INIT . call_once ( || unsafe {
35
35
let mut data: c:: WSADATA = mem:: zeroed ( ) ;
36
36
let ret = c:: WSAStartup (
37
37
0x202 , // version 2.2
@@ -42,8 +42,11 @@ pub fn init() {
42
42
}
43
43
44
44
pub fn cleanup ( ) {
45
- unsafe {
46
- c:: WSACleanup ( ) ;
45
+ if INIT . is_completed ( ) {
46
+ // only close the socket interface if it has actually been started
47
+ unsafe {
48
+ c:: WSACleanup ( ) ;
49
+ }
47
50
}
48
51
}
49
52
Original file line number Diff line number Diff line change @@ -29,10 +29,10 @@ pub fn init(argc: isize, argv: *const *const u8) {
29
29
pub fn cleanup ( ) {
30
30
static CLEANUP : Once = Once :: new ( ) ;
31
31
CLEANUP . call_once ( || unsafe {
32
- // SAFETY: Only called once during runtime cleanup.
33
- sys:: cleanup ( ) ;
34
32
// Flush stdout and disable buffering.
35
33
crate :: io:: cleanup ( ) ;
34
+ // SAFETY: Only called once during runtime cleanup.
35
+ sys:: cleanup ( ) ;
36
36
} ) ;
37
37
}
38
38
You can’t perform that action at this time.
0 commit comments