Skip to content

Commit 83aebf8

Browse files
committed
Use the correct cvt for converting socket errors on Windows.
`WSADuplicateSocketW` returns 0 on success, which differs from handle-oriented functions which return 0 on error. Use `sys::net::cvt` to handle its return value, which handles the socket convention of returning 0 on success, rather than `sys::cvt`, which handles the handle-oriented convention of returning 0 on failure.
1 parent 53e072f commit 83aebf8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

library/std/src/os/windows/io/socket.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::io;
88
use crate::marker::PhantomData;
99
use crate::mem;
1010
use crate::mem::forget;
11+
use crate::sys;
1112
use crate::sys::c;
1213
use crate::sys::cvt;
1314

@@ -80,7 +81,7 @@ impl OwnedSocket {
8081
let result = unsafe {
8182
c::WSADuplicateSocketW(self.as_raw_socket(), c::GetCurrentProcessId(), &mut info)
8283
};
83-
cvt(result)?;
84+
sys::net::cvt(result)?;
8485
let socket = unsafe {
8586
c::WSASocketW(
8687
info.iAddressFamily,

0 commit comments

Comments
 (0)