From: Jacek Caban Subject: [PATCH 05/10] server: Moved server-independent parts of pipe_server_flush into separated function. Message-Id: <073ceca0-d903-3a6a-c1f8-9e191fca2824@codeweavers.com> Date: Wed, 23 Nov 2016 11:52:30 +0100 Signed-off-by: Jacek Caban --- server/named_pipe.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/server/named_pipe.c b/server/named_pipe.c index b47892a..ad3d58e 100644 --- a/server/named_pipe.c +++ b/server/named_pipe.c @@ -551,21 +551,13 @@ static void check_flushed( void *arg ) } } -static obj_handle_t pipe_server_flush( struct fd *fd, const async_data_t *async_data, int blocking ) +static obj_handle_t pipe_end_flush( struct pipe_end *pipe_end, const async_data_t *async_data, int blocking ) { - struct pipe_server *server = get_fd_user( fd ); obj_handle_t handle = 0; struct async *async; - if (!server || server->state != ps_connected_server) return 0; - - if (!pipe_data_remaining( server )) return 0; - - if ((async = fd_queue_async( server->pipe_end.fd, async_data, NULL, ASYNC_TYPE_WAIT ))) + if ((async = fd_queue_async( pipe_end->fd, async_data, NULL, ASYNC_TYPE_WAIT ))) { - /* there's no unix way to be alerted when a pipe becomes empty, so resort to polling */ - if (!server->flush_poll) - server->flush_poll = add_timeout_user( -TICKS_PER_SEC / 10, check_flushed, server ); if (blocking) handle = alloc_handle( current->process, async, SYNCHRONIZE, 0 ); release_object( async ); set_error( STATUS_PENDING ); @@ -573,6 +565,23 @@ static obj_handle_t pipe_server_flush( struct fd *fd, const async_data_t *async_ return handle; } +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 ); + obj_handle_t handle; + + if (!server || server->state != ps_connected_server) return 0; + + if (!pipe_data_remaining( server )) return 0; + + handle = pipe_end_flush( &server->pipe_end, async_data, blocking ); + + /* there's no unix way to be alerted when a pipe becomes empty, so resort to polling */ + if (handle && !server->flush_poll) + server->flush_poll = add_timeout_user( -TICKS_PER_SEC / 10, check_flushed, server ); + return handle; +} + static obj_handle_t pipe_client_flush( struct fd *fd, const async_data_t *async, int blocking ) { /* FIXME: what do we have to do for this? */