Patch: BUGS in my recently submitted patch series
This applies over my complete patch series - I will send clean patches tomorrow.
The fixes in server/file.c and server/serial.c relate to Rein Klazes' problem. Rein: please tell me if they fix it!!
Patch http://www.winehq.com/hypermail/wine-patches/2002/04/0163.html is also needed.
Modfied files: dlls/winsock: socket.c (allocation error) server: sock.c (remove socket from select loop for blocking sockets, too) file.c (try to serve async requests immediately) serial.c (dito)
diff -ruNX ignore CVS/wine/dlls/winsock/socket.c TMP/wine/dlls/winsock/socket.c --- CVS/wine/dlls/winsock/socket.c Thu Apr 25 20:20:37 2002 +++ TMP/wine/dlls/winsock/socket.c Thu Apr 25 19:46:05 2002 @@ -2479,7 +2479,7 @@ goto error; }
- iovec = WS_ALLOC ( dwBufferCount * sizeof (struct iovec) ); + iovec = HeapAlloc (GetProcessHeap(), 0, dwBufferCount * sizeof (struct iovec) );
if ( !iovec ) { diff -ruNX ignore CVS/wine/server/file.c TMP/wine/server/file.c --- CVS/wine/server/file.c Thu Apr 25 20:20:36 2002 +++ TMP/wine/server/file.c Thu Apr 25 20:18:57 2002 @@ -389,6 +389,8 @@
if ( status == STATUS_PENDING ) { + struct pollfd pfd; + if ( !async ) async = create_async ( obj, current, ptr ); if ( !async ) @@ -397,6 +399,15 @@ 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 ); diff -ruNX ignore CVS/wine/server/serial.c TMP/wine/server/serial.c --- CVS/wine/server/serial.c Thu Apr 25 20:20:36 2002 +++ TMP/wine/server/serial.c Thu Apr 25 20:27:11 2002 @@ -282,6 +282,8 @@
if ( status == STATUS_PENDING ) { + struct pollfd pfd; + if ( !async ) async = create_async ( obj, current, ptr ); if ( !async ) @@ -293,6 +295,19 @@ 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 ); diff -ruNX ignore CVS/wine/server/sock.c TMP/wine/server/sock.c --- CVS/wine/server/sock.c Thu Apr 25 20:20:36 2002 +++ TMP/wine/server/sock.c Thu Apr 25 15:10:54 2002 @@ -250,7 +250,6 @@ 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 @@ 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,11 +333,17 @@ 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 ); } }
- sock_reselect( sock ); + 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 */ if ( sock->pmask & sock->mask || sock->flags & FD_FLAG_OVERLAPPED ) sock_wake_up( sock, event );