Skip to content

Commit eb3cf21

Browse files
committed
hook connect
1 parent 6bfd9d6 commit eb3cf21

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

core/src/syscall/unix/connect.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ impl<I: ConnectSyscall> ConnectSyscall for NioConnectSyscall<I> {
6262
set_non_blocking(fd);
6363
}
6464
let mut r = self.inner.connect(fn_ptr, fd, address, len);
65+
eprintln!("connect {r} error:{}", Error::last_os_error());
6566
loop {
6667
if r == 0 {
6768
reset_errno();
@@ -85,6 +86,7 @@ impl<I: ConnectSyscall> ConnectSyscall for NioConnectSyscall<I> {
8586
&mut len,
8687
);
8788
}
89+
eprintln!("connect getsockopt {r} error:{}", Error::last_os_error());
8890
if r != 0 {
8991
r = -1;
9092
break;
@@ -99,6 +101,7 @@ impl<I: ConnectSyscall> ConnectSyscall for NioConnectSyscall<I> {
99101
let mut address_len = std::mem::zeroed();
100102
r = libc::getpeername(fd, &mut address, &mut address_len);
101103
}
104+
eprintln!("getpeername {r} error:{}", Error::last_os_error());
102105
} else if errno != Some(libc::EINTR) {
103106
break;
104107
}

core/src/syscall/windows/connect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::syscall::common::{is_blocking, reset_errno, set_blocking, set_errno,
33
use once_cell::sync::Lazy;
44
use std::ffi::c_int;
55
use std::io::Error;
6-
use windows_sys::Win32::Networking::WinSock::{getpeername, getsockopt, SO_ERROR, SOCKADDR, SOCKET, SOL_SOCKET, WSAEALREADY, WSAEINPROGRESS, WSAEINTR, WSAETIMEDOUT};
6+
use windows_sys::Win32::Networking::WinSock::{getpeername, getsockopt, SO_ERROR, SOCKADDR, SOCKET, SOL_SOCKET, WSAEALREADY, WSAEINPROGRESS, WSAEINTR, WSAETIMEDOUT, WSAEWOULDBLOCK};
77

88
#[must_use]
99
pub extern "system" fn connect(
@@ -57,7 +57,7 @@ impl<I: ConnectSyscall> ConnectSyscall for NioConnectSyscall<I> {
5757
break;
5858
}
5959
let errno = Error::last_os_error().raw_os_error();
60-
if errno == Some(WSAEINPROGRESS) || errno == Some(WSAEALREADY) {
60+
if errno == Some(WSAEINPROGRESS) || errno == Some(WSAEALREADY) || errno == Some(WSAEWOULDBLOCK) {
6161
//阻塞,直到写事件发生
6262
if EventLoops::wait_write_event(
6363
fd as _,

0 commit comments

Comments
 (0)