INN commit: trunk (include/portable/sd-daemon.h innd/cc.c innd/innd.c)
INN Commit
rra at isc.org
Mon Jan 4 07:03:51 UTC 2021
Date: Sunday, January 3, 2021 @ 23:03:51
Author: iulius
Revision: 10482
Improve systemd integration
Revert r10475 (when sd_notify is not defined, its return value
is an integer, not void).
Check the return value and warn if the notification message was not
correctly received (it is a useful information for the administrator,
though sd_notify documentation recommends to ignore the return value
of this call).
Also, use a boolean for the first parameter, which is clearer than
a 0 or 1 int.
Modified:
trunk/include/portable/sd-daemon.h
trunk/innd/cc.c
trunk/innd/innd.c
------------------------------+
include/portable/sd-daemon.h | 4 ++--
innd/cc.c | 6 +++++-
innd/innd.c | 7 ++++++-
3 files changed, 13 insertions(+), 4 deletions(-)
Modified: include/portable/sd-daemon.h
===================================================================
--- include/portable/sd-daemon.h 2021-01-03 21:02:37 UTC (rev 10481)
+++ include/portable/sd-daemon.h 2021-01-04 07:03:51 UTC (rev 10482)
@@ -30,8 +30,8 @@
# include <systemd/sd-daemon.h>
#else
# define SD_LISTEN_FDS_START 3
-# define sd_listen_fds(u) /* empty */
-# define sd_notify(u, s) /* empty */
+# define sd_listen_fds(u) 0
+# define sd_notify(u, s) 0
#endif
#endif /* !PORTABLE_SD_DAEMON_H */
Modified: innd/cc.c
===================================================================
--- innd/cc.c 2021-01-03 21:02:37 UTC (rev 10481)
+++ innd/cc.c 2021-01-04 07:03:51 UTC (rev 10482)
@@ -180,6 +180,8 @@
CCsdnotify(void)
{
#ifdef HAVE_SD_NOTIFY
+ int status;
+
buffer_sprintf(&CCreply, "STATUS=Server ");
/* Server's mode. */
@@ -212,7 +214,9 @@
buffer_append_sprintf(&CCreply, "disabled %s.", NNRPReason);
buffer_append(&CCreply, "", 1);
- sd_notify(0, CCreply.data);
+ status = sd_notify(false, CCreply.data);
+ if (status < 0)
+ warn("cannot notify systemd of new status: %s", strerror(-status));
#endif
}
Modified: innd/innd.c
===================================================================
--- innd/innd.c 2021-01-03 21:02:37 UTC (rev 10481)
+++ innd/innd.c 2021-01-04 07:03:51 UTC (rev 10482)
@@ -364,6 +364,7 @@
bool ShouldRenumber;
bool ShouldSyntaxCheck;
pid_t pid;
+ int status;
#if defined(_DEBUG_MALLOC_INC)
union malloptarg m;
#endif /* defined(_DEBUG_MALLOC_INC) */
@@ -773,8 +774,12 @@
if (!ICDrenumberactive())
die("SERVER cant renumber");
}
+
syslog(LOG_NOTICE, "SERVER starting");
- sd_notify(0, "READY=1");
+ status = sd_notify(false, "READY=1");
+ if (status < 0)
+ warn("cannot notify systemd of startup: %s", strerror(-status));
+
CHANreadloop();
/* CHANreadloop should never return. */
More information about the inn-committers
mailing list