lkml.org 
[lkml]   [2014]   [Mar]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 25/33] Systemd Socket ID retrieval
From
Date
The socket created by systemd, waits for connections. Once it accepts a
connection, it starts the service which handles the request for a dump.

>From this service, we fetch the socket ID and perform the dump.

This is not functional yet, due to the absence of the sd-daemon.h header file.
For this we need to have the correct version of systemd which has this socket
option enabled.

Signed-off-by: Janani Venkataraman <jananive@linux.vnet.ibm.com>
---
src/coredump.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)

diff --git a/src/coredump.c b/src/coredump.c
index ab120b9..98a7146 100755
--- a/src/coredump.c
+++ b/src/coredump.c
@@ -39,6 +39,9 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <coredump.h>
+#if HAVE_SYSTEMD_SOCKET_SUPPORT
+#include <sd-daemon.h>
+#endif

/* Main Socket */
int socket_fd;
@@ -670,6 +673,35 @@ cleanup:
/* Systemd socket for self dump */
int socket_dump(void)
{
+ int n, ret;
+ char core_file[CORE_FILE_NAME_SZ];
+ struct ucred client_info;
+
+ /* Fetching the Socket ID from systemd */
+ n = sd_listen_fds(0);
+ if (n > 1) {
+ gencore_log("Too many file descriptors received.\n");
+ return -1;
+ } else if (n == 1)
+ new_sock = SD_LISTEN_FDS_START + 0;
+ else
+ return -1;
+
+ /* Receive the message */
+ ret = receive_core_filename(core_file);
+ if (ret)
+ return -1;
+
+ /* Fetch client PID */
+ ret = get_client_pid(&client_info);
+ if (ret)
+ return -1;
+
+ /* Dump process */
+ ret = dump_task(&client_info, core_file);
+ if (ret)
+ return -1;
+
return 0;
}
#endif


\
 
 \ /
  Last update: 2014-03-20 15:21    [W:0.265 / U:0.812 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site