Gitweb:
http://git.fedorahosted.org/git/?p=dlm.git;a=commitdiff;h=f545f48edeaab6a...
Commit: f545f48edeaab6a76e5c8e55a5f072d41b553597
Parent: ea0b5a37ab1bbc0f34a8ba49629d7350cfd55cd4
Author: Jacek Konieczny <jajcus(a)jajcus.net>
AuthorDate: Sat Nov 3 16:27:56 2012 +0100
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Nov 5 13:34:31 2012 -0600
Startup notification by sd_notify()
Implements simple start-up status notification via the sd_notify(3)
function from the libsystemd-daemon library. This allows proper
service startup serialization by the init daemon – services depending
on DLM will be started after dlm_controld completes the initialization.
As this pulls additional dependency, the feature my by disabled on
compile time by calling 'make' with 'USE_SD_NOTIFY=no'.
Signed-off-by: Jacek Konieczny <jajcus(a)jajcus.net>
---
dlm_controld/Makefile | 8 ++++++++
dlm_controld/main.c | 8 ++++++++
init/dlm.service | 5 +++--
3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/dlm_controld/Makefile b/dlm_controld/Makefile
index f42a913..13d6339 100644
--- a/dlm_controld/Makefile
+++ b/dlm_controld/Makefile
@@ -6,6 +6,8 @@ LIBDIR=$(PREFIX)/$(LIBNUM)
HDRDIR=$(PREFIX)/include
MANDIR=$(PREFIX)/share/man
+USE_SD_NOTIFY=yes
+
BIN_TARGET = dlm_controld
LIB_NAME = libdlmcontrol
@@ -59,6 +61,12 @@ BIN_LDFLAGS += -lpthread -lrt -lcpg -lcmap -lcfg -lquorum
LIB_CFLAGS += $(BIN_CFLAGS)
LIB_LDFLAGS += -Wl,-z,relro -pie
+ifeq ($(USE_SD_NOTIFY),yes)
+ BIN_CFLAGS += $(shell pkg-config --cflags libsystemd-daemon) \
+ -DUSE_SD_NOTIFY
+ BIN_LDFLAGS += $(shell pkg-config --libs libsystemd-daemon)
+endif
+
all: $(LIB_TARGET) $(BIN_TARGET)
$(BIN_TARGET): $(BIN_SOURCE)
diff --git a/dlm_controld/main.c b/dlm_controld/main.c
index deda60c..d1fdb2a 100644
--- a/dlm_controld/main.c
+++ b/dlm_controld/main.c
@@ -14,6 +14,10 @@
#include <linux/genetlink.h>
#include <linux/dlm_netlink.h>
+#ifdef USE_SD_NOTIFY
+#include <systemd/sd-daemon.h>
+#endif
+
#include "copyright.cf"
#include "version.cf"
@@ -1012,6 +1016,10 @@ static void loop(void)
plock_fd = rv;
plock_ci = client_add(rv, process_plocks, NULL);
+#ifdef USE_SD_NOTIFY
+ sd_notify(0, "READY=1");
+#endif
+
for (;;) {
rv = poll(pollfd, client_maxi + 1, poll_timeout);
if (rv == -1 && errno == EINTR) {
diff --git a/init/dlm.service b/init/dlm.service
index 3c4e53e..f068c63 100644
--- a/init/dlm.service
+++ b/init/dlm.service
@@ -3,10 +3,11 @@ Description=dlm control daemon
After=syslog.target network.target corosync.service sys-kernel-config.mount
[Service]
-Type=forking
+Type=notify
+NotifyAccess=main
EnvironmentFile=/etc/sysconfig/dlm
ExecStartPre=/sbin/modprobe dlm
-ExecStart=/usr/sbin/dlm_controld $DLM_CONTROLD_OPTS
+ExecStart=/usr/sbin/dlm_controld --foreground $DLM_CONTROLD_OPTS
#ExecStopPost=/sbin/modprobe -r dlm
[Install]