fix: force set tun fd when received (#1860)

This commit is contained in:
Chenx Dust
2026-02-03 11:13:31 +08:00
committed by GitHub
parent e1cbd07d1f
commit 1e2124cb99
-7
View File
@@ -106,13 +106,10 @@ impl EasyTierLauncher {
let mut tun_fd_receiver = data.tun_fd.1.lock().unwrap().take().unwrap(); let mut tun_fd_receiver = data.tun_fd.1.lock().unwrap().take().unwrap();
tasks.spawn(async move { tasks.spawn(async move {
let mut old_tun_fd = None;
loop { loop {
let Some(tun_fd) = tun_fd_receiver.recv().await.flatten() else { let Some(tun_fd) = tun_fd_receiver.recv().await.flatten() else {
return; return;
}; };
// iOS needs to re-setup nic ctx even if the tun fd is the same
if Some(tun_fd) != old_tun_fd || cfg!(target_os = "ios") {
let res = Instance::setup_nic_ctx_for_mobile( let res = Instance::setup_nic_ctx_for_mobile(
nic_ctx.clone(), nic_ctx.clone(),
global_ctx.clone(), global_ctx.clone(),
@@ -121,10 +118,6 @@ impl EasyTierLauncher {
tun_fd, tun_fd,
) )
.await; .await;
if res.is_ok() {
old_tun_fd = Some(tun_fd);
}
}
} }
}); });
} }