From 54b1fef164d94dc427490708ebadef0ec43d5f7c Mon Sep 17 00:00:00 2001 From: lbl8603 <49143209+lbl8603@users.noreply.github.com> Date: Thu, 27 Jun 2024 22:09:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnt/tun/src/windows/tun/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vnt/tun/src/windows/tun/mod.rs b/vnt/tun/src/windows/tun/mod.rs index ba421f5..f67f6f0 100644 --- a/vnt/tun/src/windows/tun/mod.rs +++ b/vnt/tun/src/windows/tun/mod.rs @@ -172,7 +172,7 @@ impl IFace for Device { fn shutdown(&self) -> io::Result<()> { unsafe { - if 0 == synchapi::SetEvent(self.shutdown_event) { + if winapi::shared::minwindef::TRUE == synchapi::SetEvent(self.shutdown_event) { Ok(()) } else { Err(io::Error::last_os_error()) @@ -284,11 +284,11 @@ impl Device { if result == winbase::WAIT_OBJECT_0 { //We have data! continue; - } else if result == winbase::WAIT_OBJECT_0 + 1 { + } else { //Shutdown event triggered return Err(io::Error::new( io::ErrorKind::Other, - "Shutdown event triggered", + format!("Shutdown event triggered {}", io::Error::last_os_error()), )); } } @@ -336,8 +336,8 @@ impl Drop for Device { } self.win_tun.WintunEndSession(self.session); self.win_tun.WintunCloseAdapter(self.adapter); - if 0 != self.win_tun.WintunDeleteDriver() { - log::warn!("WintunDeleteDriver failed") + if winapi::shared::minwindef::FALSE == self.win_tun.WintunDeleteDriver() { + log::warn!("WintunDeleteDriver failed {:?}", io::Error::last_os_error()) } } }