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

Fixed some bugs in my recently submitted patch series.

parent b0b3c385
......@@ -2487,7 +2487,7 @@ INT WINAPI WSASendTo( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
goto error;
}
iovec = WS_ALLOC ( dwBufferCount * sizeof (struct iovec) );
iovec = HeapAlloc (GetProcessHeap(), 0, dwBufferCount * sizeof (struct iovec) );
if ( !iovec )
{
......
......@@ -1562,11 +1562,6 @@ static BOOL FILE_ReadFileEx(HANDLE hFile, LPVOID buffer, DWORD bytesToRead,
WARN ( "Couldn't get FD\n" );
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));
if(!ovp)
......@@ -1790,11 +1785,6 @@ static BOOL FILE_WriteFileEx(HANDLE hFile, LPCVOID buffer, DWORD bytesToWrite,
TRACE( "Couldn't get FD\n" );
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));
if(!ovp)
......
......@@ -389,6 +389,8 @@ static void file_queue_async(struct object *obj, void *ptr, unsigned int status,
if ( status == STATUS_PENDING )
{
struct pollfd pfd;
if ( !async )
async = create_async ( obj, current, ptr );
if ( !async )
......@@ -397,6 +399,15 @@ static void file_queue_async(struct object *obj, void *ptr, unsigned int status,
async->status = STATUS_PENDING;
if ( !async->q )
async_insert( q, async );
/* Check if the new pending request can be served immediately */
pfd.fd = obj->fd;
pfd.events = file_get_poll_events ( obj );
pfd.revents = 0;
poll ( &pfd, 1, 0 );
if ( pfd.revents )
file_poll_event ( obj, pfd.revents );
}
else if ( async ) destroy_async ( async );
else set_error ( STATUS_INVALID_PARAMETER );
......
......@@ -21,6 +21,7 @@
*/
#include "config.h"
#include "wine/port.h"
#include <assert.h>
#include <fcntl.h>
......@@ -282,6 +283,8 @@ static void serial_queue_async(struct object *obj, void *ptr, unsigned int statu
if ( status == STATUS_PENDING )
{
struct pollfd pfd;
if ( !async )
async = create_async ( obj, current, ptr );
if ( !async )
......@@ -293,6 +296,19 @@ static void serial_queue_async(struct object *obj, void *ptr, unsigned int statu
async_add_timeout(async,timeout);
async_insert(q, async);
}
/* Check if the new pending request can be served immediately */
pfd.fd = obj->fd;
pfd.events = serial_get_poll_events ( obj );
pfd.revents = 0;
poll ( &pfd, 1, 0 );
if ( pfd.revents )
/* serial_poll_event() calls set_select_events() */
serial_poll_event ( obj, pfd.revents );
else
set_select_events ( obj, pfd.events );
return;
}
else if ( async ) destroy_async ( async );
else set_error ( STATUS_INVALID_PARAMETER );
......
......@@ -250,7 +250,6 @@ static void sock_poll_event( struct object *obj, int event )
sock->errors[FD_CONNECT_BIT] = sock_error( sock->obj.fd );
if (debug_level)
fprintf(stderr, "socket %d connection failure\n", sock->obj.fd);
set_select_events( &sock->obj, -1 );
}
} else
if (sock->state & FD_WINE_LISTENING)
......@@ -269,7 +268,6 @@ static void sock_poll_event( struct object *obj, int event )
sock->pmask |= FD_ACCEPT;
sock->errors[FD_ACCEPT_BIT] = sock_error( sock->obj.fd );
sock->hmask |= FD_ACCEPT;
set_select_events( &sock->obj, -1 );
}
} else
{
......@@ -335,10 +333,16 @@ static void sock_poll_event( struct object *obj, int event )
if (debug_level)
fprintf(stderr, "socket %d aborted by error %d, event: %x - removing from select loop\n",
sock->obj.fd, sock->errors[FD_CLOSE_BIT], event);
set_select_events( &sock->obj, -1 );
}
}
if ( sock->pmask & FD_CLOSE || event & (POLLERR|POLLHUP) )
{
if ( debug_level )
fprintf ( stderr, "removing socket %d from select loop\n", sock->obj.fd );
set_select_events( &sock->obj, -1 );
}
else
sock_reselect( sock );
/* wake up anyone waiting for whatever just happened */
......
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