mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-15 17:03:45 +02:00
cleanup
This commit is contained in:
parent
d66f19a2f2
commit
1828163219
1 changed files with 19 additions and 19 deletions
|
@ -50,7 +50,6 @@ impl Drop for BoundUdpSocket {
|
||||||
|
|
||||||
impl BoundUdpSocket {
|
impl BoundUdpSocket {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[inline(always)]
|
|
||||||
fn set_ttl(&self, packet_ttl: u8) {
|
fn set_ttl(&self, packet_ttl: u8) {
|
||||||
let ttl = packet_ttl as libc::c_int;
|
let ttl = packet_ttl as libc::c_int;
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -98,24 +97,6 @@ impl BoundUdpSocket {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn close(&self) {
|
|
||||||
unsafe {
|
|
||||||
self.open.store(false, Ordering::SeqCst);
|
|
||||||
let mut timeo: libc::timeval = std::mem::zeroed();
|
|
||||||
timeo.tv_sec = 0;
|
|
||||||
timeo.tv_usec = 1;
|
|
||||||
libc::setsockopt(
|
|
||||||
self.fd.as_(),
|
|
||||||
libc::SOL_SOCKET.as_(),
|
|
||||||
libc::SO_RCVTIMEO.as_(),
|
|
||||||
(&mut timeo as *mut libc::timeval).cast(),
|
|
||||||
std::mem::size_of::<libc::timeval>().as_(),
|
|
||||||
);
|
|
||||||
libc::shutdown(self.fd.as_(), libc::SHUT_RDWR);
|
|
||||||
libc::close(self.fd.as_());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Receive a packet or return None if this UDP socket is being closed.
|
/// Receive a packet or return None if this UDP socket is being closed.
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
pub fn blocking_receive<B: AsMut<[u8]>>(&self, mut buffer: B, current_time: i64) -> Option<(usize, InetAddress)> {
|
pub fn blocking_receive<B: AsMut<[u8]>>(&self, mut buffer: B, current_time: i64) -> Option<(usize, InetAddress)> {
|
||||||
|
@ -141,6 +122,25 @@ impl BoundUdpSocket {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
fn close(&self) {
|
||||||
|
unsafe {
|
||||||
|
self.open.store(false, Ordering::SeqCst);
|
||||||
|
let mut timeo: libc::timeval = std::mem::zeroed();
|
||||||
|
timeo.tv_sec = 0;
|
||||||
|
timeo.tv_usec = 1;
|
||||||
|
libc::setsockopt(
|
||||||
|
self.fd.as_(),
|
||||||
|
libc::SOL_SOCKET.as_(),
|
||||||
|
libc::SO_RCVTIMEO.as_(),
|
||||||
|
(&mut timeo as *mut libc::timeval).cast(),
|
||||||
|
std::mem::size_of::<libc::timeval>().as_(),
|
||||||
|
);
|
||||||
|
libc::shutdown(self.fd.as_(), libc::SHUT_RDWR);
|
||||||
|
libc::close(self.fd.as_());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BoundUdpPort {
|
impl BoundUdpPort {
|
||||||
|
|
Loading…
Add table
Reference in a new issue