ws2_32: Don't modify last error in async I/O callback.

This commit is contained in:
Alexandre Julliard 2007-06-01 11:15:33 +02:00
parent a1192b03d1
commit b281d3f8d8

View File

@ -1171,7 +1171,7 @@ static int WS2_recv( int fd, struct iovec* iov, int count,
if ( (n = recvmsg(fd, &hdr, *lpFlags)) == -1 ) if ( (n = recvmsg(fd, &hdr, *lpFlags)) == -1 )
{ {
TRACE( "recvmsg error %d\n", errno); TRACE( "recvmsg error %d\n", errno);
goto out; return -1;
} }
if ( lpFrom && if ( lpFrom &&
@ -1180,11 +1180,9 @@ static int WS2_recv( int fd, struct iovec* iov, int count,
/* The from buffer was too small, but we read the data /* The from buffer was too small, but we read the data
* anyway. Is that really bad? * anyway. Is that really bad?
*/ */
WSASetLastError( WSAEFAULT );
WARN( "Address buffer too small\n" ); WARN( "Address buffer too small\n" );
} }
out:
TRACE("-> %d\n", n); TRACE("-> %d\n", n);
return n; return n;
} }
@ -1197,7 +1195,7 @@ out:
static NTSTATUS WS2_async_recv( void* user, IO_STATUS_BLOCK* iosb, NTSTATUS status) static NTSTATUS WS2_async_recv( void* user, IO_STATUS_BLOCK* iosb, NTSTATUS status)
{ {
ws2_async* wsa = user; ws2_async* wsa = user;
int result = 0, fd, err; int result = 0, fd;
TRACE( "(%p %p %x)\n", wsa, iosb, status ); TRACE( "(%p %p %x)\n", wsa, iosb, status );
@ -1218,8 +1216,7 @@ static NTSTATUS WS2_async_recv( void* user, IO_STATUS_BLOCK* iosb, NTSTATUS stat
} }
else else
{ {
err = wsaErrno(); if (errno == EINTR || errno == EAGAIN)
if ( err == WSAEINTR || err == WSAEWOULDBLOCK ) /* errno: EINTR / EAGAIN */
{ {
status = STATUS_PENDING; status = STATUS_PENDING;
_enable_event( wsa->hSocket, FD_READ, 0, 0 ); _enable_event( wsa->hSocket, FD_READ, 0, 0 );
@ -1228,8 +1225,8 @@ static NTSTATUS WS2_async_recv( void* user, IO_STATUS_BLOCK* iosb, NTSTATUS stat
else else
{ {
result = 0; result = 0;
status = err; /* FIXME: is this correct ???? */ status = wsaErrno(); /* FIXME: is this correct ???? */
TRACE( "Error: %x\n", err ); TRACE( "Error: %x\n", status );
} }
} }
break; break;
@ -1260,8 +1257,8 @@ static int WS2_send( int fd, struct iovec* iov, int count,
hdr.msg_namelen = ws_sockaddr_ws2u( to, tolen, &unix_addr ); hdr.msg_namelen = ws_sockaddr_ws2u( to, tolen, &unix_addr );
if ( !hdr.msg_namelen ) if ( !hdr.msg_namelen )
{ {
WSASetLastError( WSAEFAULT ); errno = EFAULT;
return SOCKET_ERROR; return -1;
} }
#ifdef HAVE_IPX #ifdef HAVE_IPX
@ -1334,8 +1331,7 @@ static NTSTATUS WS2_async_send(void* user, IO_STATUS_BLOCK* iosb, NTSTATUS statu
} }
else else
{ {
int err = wsaErrno(); if (errno == EINTR || errno == EAGAIN)
if ( err == WSAEINTR )
{ {
status = STATUS_PENDING; status = STATUS_PENDING;
_enable_event( wsa->hSocket, FD_WRITE, 0, 0 ); _enable_event( wsa->hSocket, FD_WRITE, 0, 0 );
@ -1345,9 +1341,9 @@ static NTSTATUS WS2_async_send(void* user, IO_STATUS_BLOCK* iosb, NTSTATUS statu
{ {
/* We set the status to a winsock error code and check for that /* We set the status to a winsock error code and check for that
later in NtStatusToWSAError () */ later in NtStatusToWSAError () */
status = err; status = wsaErrno();
result = 0; result = 0;
TRACE( "Error: %x\n", err ); TRACE( "Error: %x\n", status );
} }
} }
break; break;