Implement Clone for SocketWrapper

master
Jiajie Chen 6 years ago
parent 84c12ae6e1
commit d0d05acfd0

@ -35,7 +35,7 @@ pub enum SocketType {
Icmp
}
#[derive(Clone, Debug)]
#[derive(Debug)]
pub struct SocketWrapper {
pub handle: SocketHandle,
pub socket_type: SocketType,

@ -484,6 +484,19 @@ pub fn sys_recvfrom(
}
}
impl Clone for SocketWrapper {
fn clone(&self) -> Self {
let iface = &*(NET_DRIVERS.read()[0]);
let mut sockets = iface.sockets();
sockets.retain(self.handle);
SocketWrapper {
handle: self.handle.clone(),
socket_type: self.socket_type.clone()
}
}
}
impl Drop for SocketWrapper {
fn drop(&mut self) {
let iface = &*(NET_DRIVERS.read()[0]);

Loading…
Cancel
Save