aboutsummaryrefslogtreecommitdiffstats
path: root/erts/epmd
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2014-11-25 11:53:24 +0100
committerLukas Larsson <[email protected]>2014-11-25 11:53:24 +0100
commitc181536aabe2140d3547ba34c6b7ef2ae0109c65 (patch)
treee8e7d7844481b19fb6726146c166eee9c9edf30e /erts/epmd
parent872fa86ddebbc84b07dc5426d25f7fb300731f52 (diff)
parent5db2345baa3bb9c835f91aafac3dde6e595debc7 (diff)
downloadotp-c181536aabe2140d3547ba34c6b7ef2ae0109c65.tar.gz
otp-c181536aabe2140d3547ba34c6b7ef2ae0109c65.tar.bz2
otp-c181536aabe2140d3547ba34c6b7ef2ae0109c65.zip
Merge branch 'lem/epmd_sd_notify/OTP-12321' into maint
* lem/epmd_sd_notify/OTP-12321: epmd: Unify systemd autoconf macros usage epmd: Added systemd notify support to EPMD
Diffstat (limited to 'erts/epmd')
-rw-r--r--erts/epmd/src/epmd.c20
-rw-r--r--erts/epmd/src/epmd_int.h8
-rw-r--r--erts/epmd/src/epmd_srv.c15
3 files changed, 24 insertions, 19 deletions
diff --git a/erts/epmd/src/epmd.c b/erts/epmd/src/epmd.c
index 9630e0cdf0..9699491526 100644
--- a/erts/epmd/src/epmd.c
+++ b/erts/epmd/src/epmd.c
@@ -175,9 +175,9 @@ int main(int argc, char** argv)
g->nodes.reg = g->nodes.unreg = g->nodes.unreg_tail = NULL;
g->nodes.unreg_count = 0;
g->active_conn = 0;
-#ifdef HAVE_SYSTEMD_SD_DAEMON_H
+#ifdef HAVE_SYSTEMD_DAEMON
g->is_systemd = 0;
-#endif
+#endif /* HAVE_SYSTEMD_DAEMON */
for (i = 0; i < MAX_LISTEN_SOCKETS; i++)
g->listenfd[i] = -1;
@@ -251,11 +251,11 @@ int main(int argc, char** argv)
else
usage(g);
epmd_cleanup_exit(g,0);
-#ifdef HAVE_SYSTEMD_SD_DAEMON_H
+#ifdef HAVE_SYSTEMD_DAEMON
} else if (strcmp(argv[0], "-systemd") == 0) {
g->is_systemd = 1;
argv++; argc--;
-#endif
+#endif /* HAVE_SYSTEMD_DAEMON */
} else
usage(g);
}
@@ -461,11 +461,11 @@ static void usage(EpmdVars *g)
fprintf(stderr, " Forcibly unregisters a name with epmd\n");
fprintf(stderr, " (only allowed if -relaxed_command_check was given when \n");
fprintf(stderr, " epmd was started).\n");
-#ifdef HAVE_SYSTEMD_SD_DAEMON_H
+#ifdef HAVE_SYSTEMD_DAEMON
fprintf(stderr, " -systemd\n");
fprintf(stderr, " Wait for socket from systemd. The option makes sense\n");
fprintf(stderr, " when started from .socket unit.\n");
-#endif
+#endif /* HAVE_SYSTEMD_DAEMON */
epmd_cleanup_exit(g,1);
}
@@ -593,9 +593,11 @@ void epmd_cleanup_exit(EpmdVars *g, int exitval)
for(i=0; g->argv[i] != NULL; ++i)
free(g->argv[i]);
free(g->argv);
- }
-
-
+ }
+#ifdef HAVE_SYSTEMD_DAEMON
+ sd_notifyf(0, "STATUS=Exited.\n"
+ "ERRNO=%i", exitval);
+#endif /* HAVE_SYSTEMD_DAEMON */
exit(exitval);
}
diff --git a/erts/epmd/src/epmd_int.h b/erts/epmd/src/epmd_int.h
index c8f2192f7f..52badd7086 100644
--- a/erts/epmd/src/epmd_int.h
+++ b/erts/epmd/src/epmd_int.h
@@ -125,9 +125,9 @@
# include "sys/select.h"
#endif
-#ifdef HAVE_SYSTEMD_SD_DAEMON_H
+#ifdef HAVE_SYSTEMD_DAEMON
# include <systemd/sd-daemon.h>
-#endif
+#endif /* HAVE_SYSTEMD_DAEMON */
/* ************************************************************************ */
/* Replace some functions by others by making the function name a macro */
@@ -340,9 +340,9 @@ typedef struct {
int listenfd[MAX_LISTEN_SOCKETS];
char *addresses;
char **argv;
-#ifdef HAVE_SYSTEMD_SD_DAEMON_H
+#ifdef HAVE_SYSTEMD_DAEMON
int is_systemd;
-#endif
+#endif /* HAVE_SYSTEMD_DAEMON */
} EpmdVars;
void dbg_printf(EpmdVars*,int,const char*,...);
diff --git a/erts/epmd/src/epmd_srv.c b/erts/epmd/src/epmd_srv.c
index 48fd7a5f9c..26e42adb19 100644
--- a/erts/epmd/src/epmd_srv.c
+++ b/erts/epmd/src/epmd_srv.c
@@ -244,7 +244,7 @@ void run(EpmdVars *g)
}
else
{
-#endif
+#endif /* HAVE_SYSTEMD_DAEMON */
dbg_printf(g,2,"try to initiate listening port %d", g->port);
@@ -312,7 +312,7 @@ void run(EpmdVars *g)
}
#ifdef HAVE_SYSTEMD_DAEMON
}
-#endif
+#endif /* HAVE_SYSTEMD_DAEMON */
#if !defined(__WIN32__) && !defined(__OSE__)
/* We ignore the SIGPIPE signal that is raised when we call write
@@ -330,13 +330,13 @@ void run(EpmdVars *g)
FD_ZERO(&g->orig_read_mask);
g->select_fd_top = 0;
-#ifdef HAVE_SYSTEMD_SD_DAEMON_H
+#ifdef HAVE_SYSTEMD_DAEMON
if (g->is_systemd)
for (i = 0; i < num_sockets; i++)
select_fd_set(g, listensock[i]);
else
{
-#endif
+#endif /* HAVE_SYSTEMD_DAEMON */
for (i = 0; i < num_sockets; i++)
{
if ((listensock[i] = socket(FAMILY,SOCK_STREAM,0)) < 0)
@@ -399,9 +399,12 @@ void run(EpmdVars *g)
}
select_fd_set(g, listensock[i]);
}
-#ifdef HAVE_SYSTEMD_SD_DAEMON_H
+#ifdef HAVE_SYSTEMD_DAEMON
}
-#endif
+ sd_notifyf(0, "READY=1\n"
+ "STATUS=Processing port mapping requests...\n"
+ "MAINPID=%lu", (unsigned long) getpid());
+#endif /* HAVE_SYSTEMD_DAEMON */
dbg_tty_printf(g,2,"entering the main select() loop");