From 657d43d3027ea116d3348542eac23d1d915258f0 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Wed, 24 Feb 2016 15:45:09 +0100
Subject: server: Do not allow to queue async operation for broken pipes.

---
 server/named_pipe.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/server/named_pipe.c b/server/named_pipe.c
index 2775fcab51..3542c91b4a 100644
--- a/server/named_pipe.c
+++ b/server/named_pipe.c
@@ -811,8 +811,20 @@ static obj_handle_t pipe_end_write( struct fd *fd, struct async *async, int bloc
 static void pipe_end_queue_async( struct fd *fd, struct async *async, int type, int count )
 {
     struct pipe_end *pipe_end = get_fd_user( fd );
-    if (use_server_io( pipe_end )) no_fd_queue_async( fd, async, type, count );
-    else default_fd_queue_async( fd, async, type, count );
+
+    if (use_server_io( pipe_end ))
+    {
+        no_fd_queue_async( fd, async, type, count );
+        return;
+    }
+
+    if (!pipe_end->connection)
+    {
+        set_error( STATUS_PIPE_BROKEN );
+        return;
+    }
+
+    default_fd_queue_async( fd, async, type, count );
 }
 
 static void pipe_end_reselect_async( struct fd *fd, struct async_queue *queue )
-- 
2.11.0

