From: Jacek Caban Subject: [PATCH 10/16] server: Moved server-independent parts of pipe_server_flush into separated function. Message-Id: <46fd73a7-e62e-ceac-961a-77dbd3309c46@codeweavers.com> Date: Wed, 5 Oct 2016 21:29:06 +0200 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 71492b8..c925320 100644 --- a/server/named_pipe.c +++ b/server/named_pipe.c @@ -553,21 +553,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 ); @@ -575,6 +567,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? */