From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/ntdll/unix/serial.c | 22 +++------------------- include/wine/server_protocol.h | 3 +-- server/protocol.def | 1 - server/serial.c | 31 ++++++------------------------- 4 files changed, 10 insertions(+), 47 deletions(-)
diff --git a/dlls/ntdll/unix/serial.c b/dlls/ntdll/unix/serial.c index d73ece47d0b..5af3f9afced 100644 --- a/dlls/ntdll/unix/serial.c +++ b/dlls/ntdll/unix/serial.c @@ -452,21 +452,7 @@ static NTSTATUS get_status(int fd, SERIAL_STATUS* ss) return status; }
-static void stop_waiting( HANDLE handle ) -{ - unsigned int status; - - SERVER_START_REQ( set_serial_info ) - { - req->handle = wine_server_obj_handle( handle ); - req->flags = SERIALINFO_PENDING_WAIT; - if ((status = wine_server_call( req ))) - ERR("failed to clear waiting state: %#x\n", status); - } - SERVER_END_REQ; -} - -static NTSTATUS get_wait_mask(HANDLE hDevice, UINT *mask, UINT *cookie, BOOL *pending_write, BOOL start_wait) +static NTSTATUS get_wait_mask( HANDLE hDevice, UINT *mask, UINT *cookie, BOOL *pending_write ) { unsigned int status;
@@ -474,7 +460,6 @@ static NTSTATUS get_wait_mask(HANDLE hDevice, UINT *mask, UINT *cookie, BOOL *pe { req->handle = wine_server_obj_handle( hDevice ); req->flags = pending_write ? SERIALINFO_PENDING_WRITE : 0; - if (start_wait) req->flags |= SERIALINFO_PENDING_WAIT; if (!(status = wine_server_call( req ))) { *mask = reply->eventmask; @@ -1126,7 +1111,7 @@ static BOOL async_wait_proc( void *user, ULONG_PTR *info, unsigned int *status ) } else { - get_wait_mask( commio->io.handle, &dummy, &cookie, (commio->evtmask & EV_TXEMPTY) ? &commio->pending_write : NULL, FALSE ); + get_wait_mask( commio->io.handle, &dummy, &cookie, (commio->evtmask & EV_TXEMPTY) ? &commio->pending_write : NULL ); if (commio->cookie != cookie) { *commio->events = 0; @@ -1143,7 +1128,6 @@ static BOOL async_wait_proc( void *user, ULONG_PTR *info, unsigned int *status )
if (needs_close) close( fd ); } - stop_waiting( commio->io.handle ); release_fileio( &commio->io ); return TRUE; } @@ -1161,7 +1145,7 @@ static NTSTATUS wait_on( HANDLE handle, int fd, HANDLE event, PIO_APC_ROUTINE ap
commio->events = out_buffer; commio->pending_write = 0; - status = get_wait_mask( handle, &commio->evtmask, &commio->cookie, (commio->evtmask & EV_TXEMPTY) ? &commio->pending_write : NULL, TRUE ); + status = get_wait_mask( handle, &commio->evtmask, &commio->cookie, (commio->evtmask & EV_TXEMPTY) ? &commio->pending_write : NULL ); if (status) { free( commio ); diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index 8a5ae71b856..71e28f8eac2 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -3035,7 +3035,6 @@ struct set_serial_info_reply struct reply_header __header; }; #define SERIALINFO_PENDING_WRITE 0x04 -#define SERIALINFO_PENDING_WAIT 0x08
struct cancel_sync_request @@ -6534,7 +6533,7 @@ union generic_reply
/* ### protocol_version begin ### */
-#define SERVER_PROTOCOL_VERSION 806 +#define SERVER_PROTOCOL_VERSION 807
/* ### protocol_version end ### */
diff --git a/server/protocol.def b/server/protocol.def index 25184641082..b543fdabaae 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -2256,7 +2256,6 @@ enum message_type int flags; /* bitmask to set values (see below) */ @END #define SERIALINFO_PENDING_WRITE 0x04 -#define SERIALINFO_PENDING_WAIT 0x08
/* Cancel all sync io on a thread */ @REQ(cancel_sync) diff --git a/server/serial.c b/server/serial.c index 68b489822b4..2fab9bbe7e6 100644 --- a/server/serial.c +++ b/server/serial.c @@ -78,7 +78,6 @@ struct serial unsigned int eventmask; unsigned int generation; /* event mask change counter */ unsigned int pending_write : 1; - unsigned int pending_wait : 1;
struct termios original;
@@ -144,7 +143,6 @@ struct object *create_serial( struct fd *fd ) serial->eventmask = 0; serial->generation = 0; serial->pending_write = 0; - serial->pending_wait = 0; memset( &serial->timeouts, 0, sizeof(serial->timeouts) ); init_async_queue( &serial->wait_q ); serial->fd = (struct fd *)grab_object( fd ); @@ -250,6 +248,12 @@ static void serial_ioctl( struct fd *fd, ioctl_code_t code, struct async *async { struct wait_req *req;
+ if (async_queued( &serial->wait_q )) + { + set_error( STATUS_INVALID_PARAMETER ); + return; + } + if (!(req = mem_alloc(sizeof(*req)))) return;
@@ -329,17 +333,6 @@ DECL_HANDLER(get_serial_info)
if ((serial = get_serial_obj( current->process, req->handle, 0 ))) { - if (req->flags & SERIALINFO_PENDING_WAIT) - { - if (serial->pending_wait) - { - release_object( serial ); - set_error( STATUS_INVALID_PARAMETER ); - return; - } - serial->pending_wait = 1; - } - /* event mask */ reply->eventmask = serial->eventmask; reply->cookie = serial->generation; @@ -359,18 +352,6 @@ DECL_HANDLER(set_serial_info)
if ((serial = get_serial_obj( current->process, req->handle, 0 ))) { - if (req->flags & SERIALINFO_PENDING_WAIT) - { - if (!serial->pending_wait) - { - release_object( serial ); - set_error( STATUS_INVALID_PARAMETER ); - return; - } - serial->pending_wait = 0; - } - - /* pending write */ if (req->flags & SERIALINFO_PENDING_WRITE) serial->pending_write = 1;