Update tun_handler.rs

This commit is contained in:
lbl8603
2023-01-09 11:23:08 +08:00
committed by GitHub
parent c179670b14
commit c9e3dc83ab
+3 -3
View File
@@ -130,7 +130,7 @@ fn handle_loop(
} }
} }
#[cfg(any(target_os = "macos", target_os = "linux"))] #[cfg(any(target_os = "macos", target_os = "linux", target_os = "android"))]
pub async fn handler_start<F>(mut status_watch: watch::Receiver<ApplicationStatus>, pub async fn handler_start<F>(mut status_watch: watch::Receiver<ApplicationStatus>,
udp: UdpSocket, udp: UdpSocket,
tun_reader: TunReader, tun_reader: TunReader,
@@ -139,7 +139,7 @@ pub async fn handler_start<F>(mut status_watch: watch::Receiver<ApplicationStatu
let raw_fd = tun_reader.0.as_raw_fd(); let raw_fd = tun_reader.0.as_raw_fd();
tokio::spawn(async move { tokio::spawn(async move {
let _ = status_watch.changed().await; let _ = status_watch.changed().await;
// 让tun接收线程关闭 // 让tun接收线程关闭,问题:如果改变tun配置,可能导致tun接收线程无法关闭
unsafe { unsafe {
libc::close(raw_fd); libc::close(raw_fd);
} }
@@ -154,7 +154,7 @@ pub async fn handler_start<F>(mut status_watch: watch::Receiver<ApplicationStatu
}); });
} }
#[cfg(any(target_os = "macos", target_os = "linux"))] #[cfg(any(target_os = "macos", target_os = "linux", target_os = "android"))]
pub fn handle_loop( pub fn handle_loop(
udp: UdpSocket, udp: UdpSocket,
mut tun_reader: TunReader, mut tun_reader: TunReader,