mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 18:53:39 +00:00
Fix Windows compilation errors.
This commit is contained in:
parent
18c14add39
commit
622dfcceb9
@ -7,6 +7,7 @@ use crate::convert::TryFrom;
|
||||
use crate::ffi::c_void;
|
||||
use crate::fmt;
|
||||
use crate::fs;
|
||||
use crate::io;
|
||||
use crate::marker::PhantomData;
|
||||
use crate::mem::forget;
|
||||
use crate::ptr::NonNull;
|
||||
@ -114,7 +115,7 @@ impl BorrowedHandle<'_> {
|
||||
impl OwnedHandle {
|
||||
/// Creates a new `OwnedHandle` instance that shares the same underlying file handle
|
||||
/// as the existing `OwnedHandle` instance.
|
||||
pub fn try_clone(&self) -> crate::io::Result<FileDesc> {
|
||||
pub fn try_clone(&self) -> crate::io::Result<Self> {
|
||||
let handle = self.duplicate(0, false, c::DUPLICATE_SAME_ACCESS)?;
|
||||
|
||||
Ok(unsafe { OwnedHandle::from_raw_handle(handle) })
|
||||
|
@ -4,7 +4,9 @@
|
||||
|
||||
use super::raw::{AsRawSocket, FromRawSocket, IntoRawSocket, RawSocket};
|
||||
use crate::fmt;
|
||||
use crate::io;
|
||||
use crate::marker::PhantomData;
|
||||
use crate::mem;
|
||||
use crate::mem::forget;
|
||||
use crate::sys::c;
|
||||
use crate::sys::cvt;
|
||||
@ -91,7 +93,7 @@ impl OwnedSocket {
|
||||
};
|
||||
|
||||
if socket != c::INVALID_SOCKET {
|
||||
unsafe { Ok(Self::from_inner(OwnedSocket::from_raw_socket(socket))) }
|
||||
unsafe { Ok(Self(OwnedSocket::from_raw_socket(socket))) }
|
||||
} else {
|
||||
let error = unsafe { c::WSAGetLastError() };
|
||||
|
||||
@ -115,7 +117,7 @@ impl OwnedSocket {
|
||||
}
|
||||
|
||||
unsafe {
|
||||
let socket = Self::from_inner(OwnedSocket::from_raw_socket(socket));
|
||||
let socket = Self(OwnedSocket::from_raw_socket(socket));
|
||||
socket.set_no_inherit()?;
|
||||
Ok(socket)
|
||||
}
|
||||
@ -123,6 +125,11 @@ impl OwnedSocket {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the last error from the Windows socket interface.
|
||||
fn last_error() -> io::Error {
|
||||
io::Error::from_raw_os_error(unsafe { c::WSAGetLastError() })
|
||||
}
|
||||
|
||||
impl AsRawSocket for BorrowedSocket<'_> {
|
||||
#[inline]
|
||||
fn as_raw_socket(&self) -> RawSocket {
|
||||
|
@ -455,7 +455,7 @@ impl File {
|
||||
}
|
||||
|
||||
pub fn duplicate(&self) -> io::Result<File> {
|
||||
Ok(Self(self.0.try_clone()?))
|
||||
Ok(Self { handle: self.handle.try_clone()? })
|
||||
}
|
||||
|
||||
fn reparse_point<'a>(
|
||||
|
@ -208,7 +208,7 @@ impl Socket {
|
||||
}
|
||||
|
||||
pub fn duplicate(&self) -> io::Result<Socket> {
|
||||
Ok(Self(self.0.duplicate()?))
|
||||
Ok(Self(self.0.try_clone()?))
|
||||
}
|
||||
|
||||
fn recv_with_flags(&self, buf: &mut [u8], flags: c_int) -> io::Result<usize> {
|
||||
|
Loading…
Reference in New Issue
Block a user