Skip to content

Commit 4674111

Browse files
committed
fix(net,iocp): attach before accept
1 parent dcd1708 commit 4674111

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

compio-net/src/socket.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,16 @@ impl Socket {
153153

154154
#[cfg(windows)]
155155
pub async fn accept(&self) -> io::Result<(Self, SockAddr)> {
156-
let local_addr = self.local_addr()?;
156+
let domain = self.local_addr()?.domain();
157157
let ty = self.socket.r#type()?;
158158
let protocol = self.socket.protocol()?;
159-
let accept_sock =
160-
compio_runtime::spawn_blocking(move || Socket2::new(local_addr.domain(), ty, protocol))
161-
.await?;
159+
let accept_sock = Self::new(domain, ty, protocol).await?;
162160
let op = Accept::new(self.as_raw_fd(), accept_sock.as_raw_fd() as _);
163161
let BufResult(res, op) = Runtime::current().submit(op).await;
164162
res?;
165163
op.update_context()?;
166164
let addr = op.into_addr()?;
167-
Ok((Self::from_socket2(accept_sock)?, addr))
165+
Ok((accept_sock, addr))
168166
}
169167

170168
pub fn close(self) -> impl Future<Output = io::Result<()>> {

0 commit comments

Comments
 (0)