Blame SOURCES/0326-daemon-properly-shutdown-socket-connection.patch

1a10cb
From 0a684e2c013e7a64c16dfb5b980fd4bdafaf4c9a Mon Sep 17 00:00:00 2001
1a10cb
From: Jakub Filak <jfilak@redhat.com>
1a10cb
Date: Thu, 3 Nov 2016 10:57:10 +0100
1a10cb
Subject: [PATCH] daemon: properly shutdown socket connection
1a10cb
1a10cb
Upon a new connection from a peer abrtd creates a connection fd and
1a10cb
spawns a new process that executes abrt-server. The new process
1a10cb
duplicates the connection fd to STDIN_FILENO and STDOUT_FILENO. When
1a10cb
abrt-sever is done with creation of a dump directory it sends a message
1a10cb
about that and closes STDOUT_FILENO to shut down the connection.
1a10cb
1a10cb
However, abrt-server leaves STDIN_FILENO opened and thus the connection
1a10cb
is not closed. This has a negative effect on the Python exception handler
1a10cb
that waits until the connection is closed - effectively, it delays
1a10cb
restarts of crashed processes.
1a10cb
1a10cb
Signed-off-by: Jakub Filak <jfilak@redhat.com>
1a10cb
---
1a10cb
 src/daemon/abrt-server.c | 5 +++++
1a10cb
 1 file changed, 5 insertions(+)
1a10cb
1a10cb
diff --git a/src/daemon/abrt-server.c b/src/daemon/abrt-server.c
1a10cb
index 60eb9b66..182e110e 100644
1a10cb
--- a/src/daemon/abrt-server.c
1a10cb
+++ b/src/daemon/abrt-server.c
1a10cb
@@ -624,6 +624,11 @@ static int create_problem_dir(GHashTable *problem_info, unsigned pid)
1a10cb
      */
1a10cb
     printf("HTTP/1.1 201 Created\r\n\r\n");
1a10cb
     fflush(NULL);
1a10cb
+
1a10cb
+    /* Closing STDIN_FILENO (abrtd duped the socket to stdin and stdout) and
1a10cb
+     * not-replacing it with something else to let abrt-server die on reading
1a10cb
+     * from invalid stdin - to catch bugs. */
1a10cb
+    close(STDIN_FILENO);
1a10cb
     close(STDOUT_FILENO);
1a10cb
     xdup2(STDERR_FILENO, STDOUT_FILENO); /* paranoia: don't leave stdout fd closed */
1a10cb
 
1a10cb
-- 
1a10cb
2.26.2
1a10cb