feat: made sure everything worked on Windows
This commit is contained in:
@@ -163,7 +163,6 @@ extern "C" {
|
||||
pub fn pcap_setfilter(dev: *mut PcapDev, fp: *const BpfProgram) -> c_int;
|
||||
pub fn pcap_sendpacket(p: *mut PcapDev, buf: *const c_uchar, size: c_int) -> c_int;
|
||||
pub fn pcap_setnonblock(dev: *mut PcapDev, nonblock: c_int, errbuf: *mut c_char) -> c_int;
|
||||
pub fn pcap_get_selectable_fd(p: *mut PcapDev) -> c_int;
|
||||
pub fn pcap_next_ex(
|
||||
p: *mut PcapDev,
|
||||
header: *mut *mut PktHeader,
|
||||
@@ -175,3 +174,8 @@ extern "C" {
|
||||
extern "C" {
|
||||
pub fn pcap_getevent(p: *mut PcapDev) -> windows::Win32::Foundation::HANDLE;
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
extern "C" {
|
||||
pub fn pcap_get_selectable_fd(p: *mut PcapDev) -> c_int;
|
||||
}
|
||||
|
||||
@@ -406,18 +406,18 @@ unsafe impl Sync for WaitHandle {}
|
||||
impl WaitHandle {
|
||||
#[cfg(windows)]
|
||||
pub fn wait(&self, timeout: Option<Duration>) -> error::Result<()> {
|
||||
use windows::Win32::System::Threading::{WaitForSingleObject, INFINITE};
|
||||
use windows::Win32::System::Threading::WaitForSingleObject;
|
||||
|
||||
let timeout = timeout
|
||||
.map(|t| (t.as_millis() & 0xFFFFFFFF) as u32)
|
||||
.unwrap_or(50);
|
||||
|
||||
unsafe {
|
||||
if WaitForSingleObject(self.0, timeout).0 != 0 {
|
||||
Err(std::io::Error::last_os_error()).map_err(Into::into)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
let code = unsafe { WaitForSingleObject(self.0, timeout).0 };
|
||||
|
||||
if code == 0 || code == 0x102 {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(std::io::Error::last_os_error()).map_err(Into::into)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user