kmc-solid: Implement FileDesc::duplicate

This commit is contained in:
Tomoaki Kawada 2022-01-28 14:53:54 +09:00
parent 5ab502c6d3
commit da0d506ace
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)
}
}