Rollup merge of #93410 - solid-rs:feat-kmc-solid-net-dup, r=dtolnay

kmc-solid: Implement `net::FileDesc::duplicate`

This PR implements `std::sys::solid::net::FileDesc::duplicate`, which was accidentally left out when this target was added by #86191.
This commit is contained in:
Matthias Krüger 2022-01-29 14:46:32 +01:00 committed by GitHub
commit 2836dcd2df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -175,6 +175,9 @@ extern "C" {
#[link_name = "SOLID_NET_Close"]
pub fn close(s: c_int) -> c_int;
#[link_name = "SOLID_NET_Dup"]
pub fn dup(s: c_int) -> c_int;
#[link_name = "SOLID_NET_GetPeerName"]
pub fn getpeername(s: c_int, name: *mut sockaddr, namelen: *mut socklen_t) -> c_int;

View file

@ -107,7 +107,7 @@ impl FileDesc {
}
fn duplicate(&self) -> io::Result<FileDesc> {
super::unsupported()
cvt(unsafe { netc::dup(self.fd) }).map(Self::new)
}
}