Commit 67da7ba5 authored by Alexandre Julliard's avatar Alexandre Julliard

server: Use the async queue for pipe flush requests.

parent ad53ffc9
...@@ -76,7 +76,6 @@ struct pipe_server ...@@ -76,7 +76,6 @@ struct pipe_server
struct pipe_client *client; /* client that this server is connected to */ struct pipe_client *client; /* client that this server is connected to */
struct named_pipe *pipe; struct named_pipe *pipe;
struct timeout_user *flush_poll; struct timeout_user *flush_poll;
struct event *event;
unsigned int options; /* pipe options */ unsigned int options; /* pipe options */
unsigned int pipe_flags; unsigned int pipe_flags;
}; };
...@@ -361,12 +360,9 @@ static void notify_empty( struct pipe_server *server ) ...@@ -361,12 +360,9 @@ static void notify_empty( struct pipe_server *server )
if (!server->flush_poll) if (!server->flush_poll)
return; return;
assert( server->state == ps_connected_server ); assert( server->state == ps_connected_server );
assert( server->event );
remove_timeout_user( server->flush_poll ); remove_timeout_user( server->flush_poll );
server->flush_poll = NULL; server->flush_poll = NULL;
set_event( server->event ); fd_async_wake_up( server->fd, ASYNC_TYPE_WAIT, STATUS_SUCCESS );
release_object( server->event );
server->event = NULL;
} }
static void do_disconnect( struct pipe_server *server ) static void do_disconnect( struct pipe_server *server )
...@@ -540,40 +536,33 @@ static void check_flushed( void *arg ) ...@@ -540,40 +536,33 @@ static void check_flushed( void *arg )
{ {
struct pipe_server *server = (struct pipe_server*) arg; struct pipe_server *server = (struct pipe_server*) arg;
assert( server->event );
if (pipe_data_remaining( server )) if (pipe_data_remaining( server ))
{ {
server->flush_poll = add_timeout_user( -TICKS_PER_SEC / 10, check_flushed, server ); server->flush_poll = add_timeout_user( -TICKS_PER_SEC / 10, check_flushed, server );
} }
else else
{ {
/* notify_empty( server ); */
server->flush_poll = NULL; server->flush_poll = NULL;
set_event( server->event ); fd_async_wake_up( server->fd, ASYNC_TYPE_WAIT, STATUS_SUCCESS );
release_object( server->event );
server->event = NULL;
} }
} }
static obj_handle_t pipe_server_flush( struct fd *fd, const async_data_t *async, int blocking ) static obj_handle_t pipe_server_flush( struct fd *fd, const async_data_t *async_data, int blocking )
{ {
struct pipe_server *server = get_fd_user( fd ); struct pipe_server *server = get_fd_user( fd );
obj_handle_t handle = 0; obj_handle_t handle = 0;
struct async *async;
if (!server || server->state != ps_connected_server) return 0; if (!server || server->state != ps_connected_server) return 0;
/* FIXME: if multiple threads flush the same pipe, if (!pipe_data_remaining( server )) return 0;
maybe should create a list of processes to notify */
if (server->flush_poll) return 0;
if (pipe_data_remaining( server )) if ((async = fd_queue_async( server->fd, async_data, ASYNC_TYPE_WAIT )))
{ {
/* this kind of sux - /* there's no unix way to be alerted when a pipe becomes empty, so resort to polling */
there's no unix way to be alerted when a pipe becomes empty */ if (!server->flush_poll)
server->event = create_event( NULL, NULL, 0, 0, 0, NULL ); server->flush_poll = add_timeout_user( -TICKS_PER_SEC / 10, check_flushed, server );
if (!server->event) return 0; if (blocking) handle = alloc_handle( current->process, async, SYNCHRONIZE, 0 );
server->flush_poll = add_timeout_user( -TICKS_PER_SEC / 10, check_flushed, server );
handle = alloc_handle( current->process, server->event, SYNCHRONIZE, 0 );
set_error( STATUS_PENDING ); set_error( STATUS_PENDING );
} }
return handle; return handle;
......
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