diff mbox

[rdma-core,3/4] iwpmd: Use sd_notify to synchronize bootup

Message ID 1501797846-8228-4-git-send-email-jgunthorpe@obsidianresearch.com (mailing list archive)
State Accepted
Headers show

Commit Message

Jason Gunthorpe Aug. 3, 2017, 10:04 p.m. UTC
Tell systemd that iwpmd is ready once it established all threads and
netlink sockets.

This perhaps should be pushed a little later, after the message sent
by send_iwpm_mapinfo_request is responded to by the kernel?

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
---
 iwpmd/CMakeLists.txt    | 1 +
 iwpmd/iwarp_pm_server.c | 5 +++++
 iwpmd/iwpmd.service.in  | 1 +
 3 files changed, 7 insertions(+)
diff mbox

Patch

diff --git a/iwpmd/CMakeLists.txt b/iwpmd/CMakeLists.txt
index 6fd36e47bbbc54..bf538034ea5333 100644
--- a/iwpmd/CMakeLists.txt
+++ b/iwpmd/CMakeLists.txt
@@ -4,6 +4,7 @@  rdma_sbin_executable(iwpmd
   iwarp_pm_server.c
   )
 target_link_libraries(iwpmd LINK_PRIVATE
+  ${SYSTEMD_LIBRARIES}
   ${NL_LIBRARIES}
   ${CMAKE_THREAD_LIBS_INIT}
   )
diff --git a/iwpmd/iwarp_pm_server.c b/iwpmd/iwarp_pm_server.c
index 637f2344d98402..ebed6f9d28ee59 100644
--- a/iwpmd/iwarp_pm_server.c
+++ b/iwpmd/iwarp_pm_server.c
@@ -32,6 +32,7 @@ 
  */
 
 #include "config.h"
+#include <systemd/sd-daemon.h>
 #include <getopt.h>
 #include "iwarp_pm.h"
 
@@ -1447,6 +1448,10 @@  int main(int argc, char *argv[])
 
 	known_clients = init_iwpm_clients(&iwarp_clients[0]);
 	send_iwpm_mapinfo_request(netlink_sock, &iwarp_clients[0], known_clients);
+
+	if (systemd)
+		sd_notify(0, "READY=1");
+
 	iwarp_port_mapper(); /* start iwarp port mapper process */
 
 	free_iwpm_mapped_ports();
diff --git a/iwpmd/iwpmd.service.in b/iwpmd/iwpmd.service.in
index 4e4b49738fa29d..3451e7e50923af 100644
--- a/iwpmd/iwpmd.service.in
+++ b/iwpmd/iwpmd.service.in
@@ -5,6 +5,7 @@  Requires=rdma-load-modules@iwpmd.service
 After=network.target rdma-load-modules@iwpmd.service
 
 [Service]
+Type=notify
 ExecStart=@CMAKE_INSTALL_FULL_SBINDIR@/iwpmd --systemd
 LimitNOFILE=102400