@@ -14,7 +14,7 @@ use windows_sys::Win32::Networking::WinSock::{
1414 getsockopt, setsockopt, AcceptEx , WSAGetLastError , WSARecv , WSASend , WSASocketW ,
1515 INVALID_SOCKET , LPCONDITIONPROC , LPWSAOVERLAPPED_COMPLETION_ROUTINE , SEND_RECV_FLAGS , SOCKADDR ,
1616 SOCKADDR_IN , SOCKET , SOCKET_ERROR , SOL_SOCKET , SO_PROTOCOL_INFO , SO_UPDATE_ACCEPT_CONTEXT ,
17- WSABUF , WSAPROTOCOL_INFOW , WSA_FLAG_OVERLAPPED , WSA_IO_PENDING ,
17+ WSABUF , WSAEINPROGRESS , WSAENETDOWN , WSAPROTOCOL_INFOW , WSA_FLAG_OVERLAPPED , WSA_IO_PENDING ,
1818} ;
1919use windows_sys:: Win32 :: Storage :: FileSystem :: SetFileCompletionNotificationModes ;
2020use windows_sys:: Win32 :: System :: WindowsProgramming :: FILE_SKIP_SET_EVENT_ON_HANDLE ;
@@ -159,7 +159,6 @@ impl<'o> Operator<'o> {
159159 for entry in entries {
160160 let mut cqe = * Box :: from_raw ( entry. lpOverlapped . cast :: < Overlapped > ( ) ) ;
161161 // resolve completed read/write tasks
162- // todo refactor IOCP impl
163162 cqe. result = match cqe. syscall_name {
164163 SyscallName :: accept => {
165164 if setsockopt (
@@ -172,7 +171,7 @@ impl<'o> Operator<'o> {
172171 {
173172 cqe. socket . try_into ( ) . expect ( "result overflow" )
174173 } else {
175- -c_longlong:: from ( windows_sys :: Win32 :: Foundation :: GetLastError ( ) )
174+ -c_longlong:: from ( WSAENETDOWN )
176175 }
177176 }
178177 SyscallName :: recv
@@ -183,7 +182,7 @@ impl<'o> Operator<'o> {
183182 if r > 0 {
184183 r
185184 } else {
186- -c_longlong:: from ( windows_sys :: Win32 :: Foundation :: GetLastError ( ) )
185+ -c_longlong:: from ( WSAEINPROGRESS )
187186 }
188187 }
189188 _ => panic ! ( "unsupported" ) ,
@@ -364,6 +363,7 @@ impl<'o> Operator<'o> {
364363 overlapped. from_fd = fd;
365364 overlapped. token = user_data;
366365 overlapped. syscall_name = syscall_name;
366+ overlapped. result = -1 ;
367367 if WSARecv (
368368 fd,
369369 buf,
@@ -457,6 +457,7 @@ impl<'o> Operator<'o> {
457457 overlapped. from_fd = fd;
458458 overlapped. token = user_data;
459459 overlapped. syscall_name = syscall_name;
460+ overlapped. result = -1 ;
460461 if WSASend (
461462 fd,
462463 buf,
0 commit comments