server: Directly wake up wait asyncs when the serial mask changes.

This commit is contained in:
Elizabeth Figura 2024-05-28 18:45:27 -05:00 committed by Alexandre Julliard
parent 6b7834d407
commit aa0ab31571
Notes: Alexandre Julliard 2024-06-18 23:12:34 +02:00
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/wine/-/merge_requests/5862
6 changed files with 10 additions and 30 deletions

View file

@ -452,7 +452,7 @@ static NTSTATUS get_status(int fd, SERIAL_STATUS* ss)
return status; return status;
} }
static NTSTATUS get_wait_mask( HANDLE hDevice, UINT *mask, UINT *cookie, BOOL *pending_write ) static NTSTATUS get_wait_mask( HANDLE hDevice, UINT *mask, BOOL *pending_write )
{ {
unsigned int status; unsigned int status;
@ -463,7 +463,6 @@ static NTSTATUS get_wait_mask( HANDLE hDevice, UINT *mask, UINT *cookie, BOOL *p
if (!(status = wine_server_call( req ))) if (!(status = wine_server_call( req )))
{ {
*mask = reply->eventmask; *mask = reply->eventmask;
if (cookie) *cookie = reply->cookie;
if (pending_write) *pending_write = reply->pending_write; if (pending_write) *pending_write = reply->pending_write;
} }
} }
@ -967,7 +966,6 @@ typedef struct async_commio
struct async_fileio io; struct async_fileio io;
DWORD* events; DWORD* events;
UINT evtmask; UINT evtmask;
UINT cookie;
UINT mstat; UINT mstat;
BOOL pending_write; BOOL pending_write;
serial_irq_info irq_info; serial_irq_info irq_info;
@ -1080,7 +1078,7 @@ static BOOL async_wait_proc( void *user, ULONG_PTR *info, unsigned int *status )
if (!server_get_unix_fd( commio->io.handle, FILE_READ_DATA | FILE_WRITE_DATA, &fd, &needs_close, NULL, NULL )) if (!server_get_unix_fd( commio->io.handle, FILE_READ_DATA | FILE_WRITE_DATA, &fd, &needs_close, NULL, NULL ))
{ {
serial_irq_info new_irq_info; serial_irq_info new_irq_info;
UINT new_mstat, dummy, cookie; UINT new_mstat, dummy;
TRACE( "device=%p fd=0x%08x mask=0x%08x buffer=%p irq_info=%p\n", TRACE( "device=%p fd=0x%08x mask=0x%08x buffer=%p irq_info=%p\n",
commio->io.handle, fd, commio->evtmask, commio->events, &commio->irq_info ); commio->io.handle, fd, commio->evtmask, commio->events, &commio->irq_info );
@ -1111,18 +1109,9 @@ static BOOL async_wait_proc( void *user, ULONG_PTR *info, unsigned int *status )
} }
else else
{ {
get_wait_mask( commio->io.handle, &dummy, &cookie, (commio->evtmask & EV_TXEMPTY) ? &commio->pending_write : NULL ); get_wait_mask( commio->io.handle, &dummy, (commio->evtmask & EV_TXEMPTY) ? &commio->pending_write : NULL );
if (commio->cookie != cookie) if (needs_close) close( fd );
{ return FALSE;
*commio->events = 0;
*status = STATUS_CANCELLED;
*info = 0;
}
else
{
if (needs_close) close( fd );
return FALSE;
}
} }
} }
@ -1145,7 +1134,7 @@ static NTSTATUS wait_on( HANDLE handle, int fd, HANDLE event, PIO_APC_ROUTINE ap
commio->events = out_buffer; commio->events = out_buffer;
commio->pending_write = 0; commio->pending_write = 0;
status = get_wait_mask( handle, &commio->evtmask, &commio->cookie, (commio->evtmask & EV_TXEMPTY) ? &commio->pending_write : NULL ); status = get_wait_mask( handle, &commio->evtmask, (commio->evtmask & EV_TXEMPTY) ? &commio->pending_write : NULL );
if (status) if (status)
{ {
free( commio ); free( commio );

View file

@ -3016,9 +3016,7 @@ struct get_serial_info_reply
{ {
struct reply_header __header; struct reply_header __header;
unsigned int eventmask; unsigned int eventmask;
unsigned int cookie;
unsigned int pending_write; unsigned int pending_write;
char __pad_20[4];
}; };
@ -6533,7 +6531,7 @@ union generic_reply
/* ### protocol_version begin ### */ /* ### protocol_version begin ### */
#define SERVER_PROTOCOL_VERSION 807 #define SERVER_PROTOCOL_VERSION 808
/* ### protocol_version end ### */ /* ### protocol_version end ### */

View file

@ -2245,7 +2245,6 @@ enum message_type
int flags; int flags;
@REPLY @REPLY
unsigned int eventmask; unsigned int eventmask;
unsigned int cookie;
unsigned int pending_write; unsigned int pending_write;
@END @END

View file

@ -1455,9 +1455,8 @@ C_ASSERT( FIELD_OFFSET(struct get_serial_info_request, handle) == 12 );
C_ASSERT( FIELD_OFFSET(struct get_serial_info_request, flags) == 16 ); C_ASSERT( FIELD_OFFSET(struct get_serial_info_request, flags) == 16 );
C_ASSERT( sizeof(struct get_serial_info_request) == 24 ); C_ASSERT( sizeof(struct get_serial_info_request) == 24 );
C_ASSERT( FIELD_OFFSET(struct get_serial_info_reply, eventmask) == 8 ); C_ASSERT( FIELD_OFFSET(struct get_serial_info_reply, eventmask) == 8 );
C_ASSERT( FIELD_OFFSET(struct get_serial_info_reply, cookie) == 12 ); C_ASSERT( FIELD_OFFSET(struct get_serial_info_reply, pending_write) == 12 );
C_ASSERT( FIELD_OFFSET(struct get_serial_info_reply, pending_write) == 16 ); C_ASSERT( sizeof(struct get_serial_info_reply) == 16 );
C_ASSERT( sizeof(struct get_serial_info_reply) == 24 );
C_ASSERT( FIELD_OFFSET(struct set_serial_info_request, handle) == 12 ); C_ASSERT( FIELD_OFFSET(struct set_serial_info_request, handle) == 12 );
C_ASSERT( FIELD_OFFSET(struct set_serial_info_request, flags) == 16 ); C_ASSERT( FIELD_OFFSET(struct set_serial_info_request, flags) == 16 );
C_ASSERT( sizeof(struct set_serial_info_request) == 24 ); C_ASSERT( sizeof(struct set_serial_info_request) == 24 );

View file

@ -76,7 +76,6 @@ struct serial
struct timeout_user *read_timer; struct timeout_user *read_timer;
SERIAL_TIMEOUTS timeouts; SERIAL_TIMEOUTS timeouts;
unsigned int eventmask; unsigned int eventmask;
unsigned int generation; /* event mask change counter */
unsigned int pending_write : 1; unsigned int pending_write : 1;
struct termios original; struct termios original;
@ -141,7 +140,6 @@ struct object *create_serial( struct fd *fd )
serial->read_timer = NULL; serial->read_timer = NULL;
serial->eventmask = 0; serial->eventmask = 0;
serial->generation = 0;
serial->pending_write = 0; serial->pending_write = 0;
memset( &serial->timeouts, 0, sizeof(serial->timeouts) ); memset( &serial->timeouts, 0, sizeof(serial->timeouts) );
init_async_queue( &serial->wait_q ); init_async_queue( &serial->wait_q );
@ -240,8 +238,7 @@ static void serial_ioctl( struct fd *fd, ioctl_code_t code, struct async *async
return; return;
} }
serial->eventmask = *(unsigned int *)get_req_data(); serial->eventmask = *(unsigned int *)get_req_data();
serial->generation++; async_wake_up( &serial->wait_q, STATUS_CANCELLED );
fd_async_wake_up( serial->fd, ASYNC_TYPE_WAIT, STATUS_SUCCESS );
return; return;
case IOCTL_SERIAL_WAIT_ON_MASK: case IOCTL_SERIAL_WAIT_ON_MASK:
@ -335,7 +332,6 @@ DECL_HANDLER(get_serial_info)
{ {
/* event mask */ /* event mask */
reply->eventmask = serial->eventmask; reply->eventmask = serial->eventmask;
reply->cookie = serial->generation;
/* pending write */ /* pending write */
reply->pending_write = serial->pending_write; reply->pending_write = serial->pending_write;

View file

@ -2856,7 +2856,6 @@ static void dump_get_serial_info_request( const struct get_serial_info_request *
static void dump_get_serial_info_reply( const struct get_serial_info_reply *req ) static void dump_get_serial_info_reply( const struct get_serial_info_reply *req )
{ {
fprintf( stderr, " eventmask=%08x", req->eventmask ); fprintf( stderr, " eventmask=%08x", req->eventmask );
fprintf( stderr, ", cookie=%08x", req->cookie );
fprintf( stderr, ", pending_write=%08x", req->pending_write ); fprintf( stderr, ", pending_write=%08x", req->pending_write );
} }