From d8726b07c33fd9779c731fb5fcdef4accd8ed8b6 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Fri, 6 Dec 2024 17:13:24 +0100
Subject: [PATCH 4/5] lvmlockd: utilize SD_NOTIFY_SUPPORT

Update makefile and code to better utilize SD_NOTIFY_SUPPORT var.
---
 daemons/lvmlockd/Makefile.in     | 3 +--
 daemons/lvmlockd/lvmlockd-core.c | 4 ++--
 include/configure.h.in           | 3 +++
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/daemons/lvmlockd/Makefile.in b/daemons/lvmlockd/Makefile.in
index 61dae4e9b8ff..7ae4b3da3e94 100644
--- a/daemons/lvmlockd/Makefile.in
+++ b/daemons/lvmlockd/Makefile.in
@@ -50,8 +50,7 @@ INCLUDES += -I$(top_srcdir)/libdaemon/server
 LDFLAGS += -L$(top_builddir)/libdaemon/server $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS)
 LIBS += $(DAEMON_LIBS) $(PTHREAD_LIBS)
 
-ifneq (,$(firstword $(LIBSYSTEMD_LIBS)))
-	DEFS += -DUSE_SD_NOTIFY
+ifeq ("@SD_NOTIFY_SUPPORT@", "yes")
 	CFLAGS += $(LIBSYSTEMD_CFLAGS)
 	LIBS += $(LIBSYSTEMD_LIBS)
 endif
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index 327311b2fe90..107e9c19d3b7 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -31,7 +31,7 @@
 #include <sys/utsname.h>
 #include <sys/un.h>
 
-#ifdef USE_SD_NOTIFY
+#ifdef SD_NOTIFY_SUPPORT
 #include <systemd/sd-daemon.h>
 #endif
 
@@ -6123,7 +6123,7 @@ static int main_loop(daemon_state *ds_arg)
 	setup_worker_thread();
 	setup_restart();
 
-#ifdef USE_SD_NOTIFY
+#ifdef SD_NOTIFY_SUPPORT
 	sd_notify(0, "READY=1");
 #endif
 
diff --git a/include/configure.h.in b/include/configure.h.in
index 1dabd23c6376..3c27d219b4c0 100644
--- a/include/configure.h.in
+++ b/include/configure.h.in
@@ -660,6 +660,9 @@
 /* Define to 1 to include the LVM readline shell. */
 #undef READLINE_SUPPORT
 
+/* Define to 1 to include code that uses sd_notify. */
+#undef SD_NOTIFY_SUPPORT
+
 /* Define to 1 to include built-in support for snapshots. */
 #undef SNAPSHOT_INTERNAL
 
-- 
2.39.5 (Apple Git-154)

