Commit af16c98f authored by Martin Wilck's avatar Martin Wilck Committed by Alexandre Julliard

Implemented overlapped WSARecvFrom(), WSASendTo(), and

WSAGetOverlappedResult(). Fixed shutdown() to work correctly for overlapped sockets (do not actually do a shutdown() system call as long as there are pending overlapped requests). Also added correct error reporting when trying to read or write on a shut down connection, also for ReadFile()/WriteFile() calls.
parent bff7e699
...@@ -52,7 +52,7 @@ debug_channels (winsock) ...@@ -52,7 +52,7 @@ debug_channels (winsock)
37 stdcall WSAEnumProtocolsA(ptr ptr ptr) WSAEnumProtocolsA 37 stdcall WSAEnumProtocolsA(ptr ptr ptr) WSAEnumProtocolsA
38 stdcall WSAEnumProtocolsW(ptr ptr ptr) WSAEnumProtocolsW 38 stdcall WSAEnumProtocolsW(ptr ptr ptr) WSAEnumProtocolsW
39 stdcall WSAEventSelect(long long long) WSAEventSelect 39 stdcall WSAEventSelect(long long long) WSAEventSelect
40 stub WSAGetOverlappedResult 40 stdcall WSAGetOverlappedResult(long ptr ptr long ptr) WSAGetOverlappedResult
41 stub WSAGetQOSByName 41 stub WSAGetQOSByName
42 stub WSAGetServiceClassInfoA 42 stub WSAGetServiceClassInfoA
43 stub WSAGetServiceClassInfoW 43 stub WSAGetServiceClassInfoW
......
...@@ -300,12 +300,20 @@ HANDLE FILE_DupUnixHandle( int fd, DWORD access, BOOL inherit ) ...@@ -300,12 +300,20 @@ HANDLE FILE_DupUnixHandle( int fd, DWORD access, BOOL inherit )
* Retrieve the Unix handle corresponding to a file handle. * Retrieve the Unix handle corresponding to a file handle.
* Returns -1 on failure. * Returns -1 on failure.
*/ */
static int FILE_GetUnixHandleType( HANDLE handle, DWORD access, enum fd_type *type, int *flags ) static int FILE_GetUnixHandleType( HANDLE handle, DWORD access, enum fd_type *type, int *flags_ptr )
{ {
int ret, fd = -1; int ret, flags, fd = -1;
ret = wine_server_handle_to_fd( handle, access, &fd, type, flags ); ret = wine_server_handle_to_fd( handle, access, &fd, type, &flags );
if (flags_ptr) *flags_ptr = flags;
if (ret) SetLastError( RtlNtStatusToDosError(ret) ); if (ret) SetLastError( RtlNtStatusToDosError(ret) );
else if (((access & GENERIC_READ) && (flags & FD_FLAG_RECV_SHUTDOWN)) ||
((access & GENERIC_WRITE) && (flags & FD_FLAG_SEND_SHUTDOWN)))
{
close (fd);
SetLastError ( ERROR_PIPE_NOT_CONNECTED );
return -1;
}
return fd; return fd;
} }
...@@ -1411,7 +1419,7 @@ BOOL WINAPI GetOverlappedResult( ...@@ -1411,7 +1419,7 @@ BOOL WINAPI GetOverlappedResult(
*lpTransferred = lpOverlapped->InternalHigh; *lpTransferred = lpOverlapped->InternalHigh;
SetLastError ( lpOverlapped->Internal == STATUS_PENDING ? SetLastError ( lpOverlapped->Internal == STATUS_PENDING ?
ERROR_IO_INCOMPLETE : lpOverlapped->Internal ); ERROR_IO_INCOMPLETE : RtlNtStatusToDosError ( lpOverlapped->Internal ) );
return (r==WAIT_OBJECT_0); return (r==WAIT_OBJECT_0);
} }
...@@ -1511,9 +1519,13 @@ static BOOL FILE_ReadFileEx(HANDLE hFile, LPVOID buffer, DWORD bytesToRead, ...@@ -1511,9 +1519,13 @@ static BOOL FILE_ReadFileEx(HANDLE hFile, LPVOID buffer, DWORD bytesToRead,
if ( fd < 0 ) if ( fd < 0 )
{ {
WARN ( "Couldn't get FD\n" ); WARN ( "Couldn't get FD\n" );
SetLastError ( ERROR_INVALID_PARAMETER );
return FALSE; return FALSE;
} }
if ( ! (flags & FD_FLAG_OVERLAPPED) ) {
WARN ( "fd is not overlapped\n" );
SetLastError ( ERROR_INVALID_PARAMETER );
goto error;
}
ovp = (async_fileio*) HeapAlloc(GetProcessHeap(), 0, sizeof (async_fileio)); ovp = (async_fileio*) HeapAlloc(GetProcessHeap(), 0, sizeof (async_fileio));
if(!ovp) if(!ovp)
...@@ -1731,6 +1743,11 @@ static BOOL FILE_WriteFileEx(HANDLE hFile, LPCVOID buffer, DWORD bytesToWrite, ...@@ -1731,6 +1743,11 @@ static BOOL FILE_WriteFileEx(HANDLE hFile, LPCVOID buffer, DWORD bytesToWrite,
TRACE( "Couldn't get FD\n" ); TRACE( "Couldn't get FD\n" );
return FALSE; return FALSE;
} }
if ( ! (flags & FD_FLAG_OVERLAPPED) ) {
WARN ( "fd is not overlapped\n" );
SetLastError ( ERROR_INVALID_PARAMETER );
goto error;
}
ovp = (async_fileio*) HeapAlloc(GetProcessHeap(), 0, sizeof (async_fileio)); ovp = (async_fileio*) HeapAlloc(GetProcessHeap(), 0, sizeof (async_fileio));
if(!ovp) if(!ovp)
......
...@@ -458,7 +458,7 @@ typedef struct { ...@@ -458,7 +458,7 @@ typedef struct {
/* The 'overlapped' data structure used by async I/O functions. /* The 'overlapped' data structure used by async I/O functions.
*/ */
typedef struct { typedef struct _OVERLAPPED {
DWORD Internal; DWORD Internal;
DWORD InternalHigh; DWORD InternalHigh;
DWORD Offset; DWORD Offset;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment