about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorDan Gohman <dev@sunfishcode.online>2022-01-12 11:41:48 -0800
committerDan Gohman <dev@sunfishcode.online>2022-01-12 11:41:48 -0800
commit83aebf8f7bb6d766f6b68accdc44acb9cea3d57e (patch)
tree2bc157e436a00d61c042503cea2e9629122194d6 /library/std/src
parent53e072f2207747e8b60dcbb77b763c1598cfb192 (diff)
downloadrust-83aebf8f7bb6d766f6b68accdc44acb9cea3d57e.tar.gz
rust-83aebf8f7bb6d766f6b68accdc44acb9cea3d57e.zip
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.
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/os/windows/io/socket.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/library/std/src/os/windows/io/socket.rs b/library/std/src/os/windows/io/socket.rs
index e0af4f1f6cb..26b569bcdd3 100644
--- a/library/std/src/os/windows/io/socket.rs
+++ b/library/std/src/os/windows/io/socket.rs
@@ -8,6 +8,7 @@ use crate::io;
 use crate::marker::PhantomData;
 use crate::mem;
 use crate::mem::forget;
+use crate::sys;
 use crate::sys::c;
 use crate::sys::cvt;
 
@@ -80,7 +81,7 @@ impl OwnedSocket {
         let result = unsafe {
             c::WSADuplicateSocketW(self.as_raw_socket(), c::GetCurrentProcessId(), &mut info)
         };
-        cvt(result)?;
+        sys::net::cvt(result)?;
         let socket = unsafe {
             c::WSASocketW(
                 info.iAddressFamily,