summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/basic/cpu-set-util.c1
-rw-r--r--src/basic/def.h21
-rw-r--r--src/basic/escape.c1
-rw-r--r--src/basic/extract-word.c3
-rw-r--r--src/basic/glob-util.c1
-rw-r--r--src/basic/glob-util.h2
-rw-r--r--src/basic/macro.h15
-rw-r--r--src/basic/replace-var.c4
-rw-r--r--src/basic/string-util.c2
-rw-r--r--src/basic/string-util.h12
-rw-r--r--src/basic/util.h7
-rw-r--r--src/binfmt/binfmt.c1
-rw-r--r--src/bootchart/bootchart.c1
-rw-r--r--src/journal-remote/journal-remote.c1
-rw-r--r--src/journal-remote/journal-upload.c1
-rw-r--r--src/journal/journald-server.c62
-rw-r--r--src/journal/journald-server.h13
-rw-r--r--src/libsystemd-network/sd-dhcp-lease.c3
-rw-r--r--src/libsystemd/sd-daemon/sd-daemon.c2
-rw-r--r--src/login/logind.c1
-rw-r--r--src/modules-load/modules-load.c1
-rw-r--r--src/resolve/resolved-conf.c1
-rw-r--r--src/shared/sleep-config.c3
-rw-r--r--src/sysctl/sysctl.c1
-rw-r--r--src/sysusers/sysusers.c5
-rw-r--r--src/timesync/timesyncd-conf.c5
-rw-r--r--src/tmpfiles/tmpfiles.c1
-rw-r--r--units/systemd-journald.service.in1
28 files changed, 122 insertions, 50 deletions
diff --git a/src/basic/cpu-set-util.c b/src/basic/cpu-set-util.c
index 4950c66767..e2ec4ca83f 100644
--- a/src/basic/cpu-set-util.c
+++ b/src/basic/cpu-set-util.c
@@ -24,6 +24,7 @@
#include "cpu-set-util.h"
#include "extract-word.h"
#include "parse-util.h"
+#include "string-util.h"
#include "util.h"
cpu_set_t* cpu_set_malloc(unsigned *ncpus) {
diff --git a/src/basic/def.h b/src/basic/def.h
index cbef137410..950f693899 100644
--- a/src/basic/def.h
+++ b/src/basic/def.h
@@ -43,12 +43,6 @@
#define SIGNALS_CRASH_HANDLER SIGSEGV,SIGILL,SIGFPE,SIGBUS,SIGQUIT,SIGABRT
#define SIGNALS_IGNORE SIGPIPE
-#define DIGITS "0123456789"
-#define LOWERCASE_LETTERS "abcdefghijklmnopqrstuvwxyz"
-#define UPPERCASE_LETTERS "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-#define LETTERS LOWERCASE_LETTERS UPPERCASE_LETTERS
-#define ALPHANUMERICAL LETTERS DIGITS
-
#define REBOOT_PARAM_FILE "/run/systemd/reboot-param"
#ifdef HAVE_SPLIT_USR
@@ -81,3 +75,18 @@
#define NOTIFY_FD_MAX 768
#define NOTIFY_BUFFER_MAX PIPE_BUF
+
+/* Return a nulstr for a standard cascade of configuration directories,
+ * suitable to pass to conf_files_list_nulstr or config_parse_many. */
+#define CONF_DIRS_NULSTR(n) \
+ "/etc/" n ".d\0" \
+ "/run/" n ".d\0" \
+ "/usr/local/lib/" n ".d\0" \
+ "/usr/lib/" n ".d\0" \
+ CONF_DIR_SPLIT_USR(n)
+
+#ifdef HAVE_SPLIT_USR
+#define CONF_DIR_SPLIT_USR(n) "/lib/" n ".d\0"
+#else
+#define CONF_DIR_SPLIT_USR(n)
+#endif
diff --git a/src/basic/escape.c b/src/basic/escape.c
index add0d7795b..4815161b09 100644
--- a/src/basic/escape.c
+++ b/src/basic/escape.c
@@ -22,6 +22,7 @@
#include "alloc-util.h"
#include "escape.h"
#include "hexdecoct.h"
+#include "string-util.h"
#include "utf8.h"
#include "util.h"
diff --git a/src/basic/extract-word.c b/src/basic/extract-word.c
index c0f9394fad..6721b85c0a 100644
--- a/src/basic/extract-word.c
+++ b/src/basic/extract-word.c
@@ -21,9 +21,10 @@
#include "alloc-util.h"
#include "escape.h"
+#include "extract-word.h"
+#include "string-util.h"
#include "utf8.h"
#include "util.h"
-#include "extract-word.h"
int extract_first_word(const char **p, char **ret, const char *separators, ExtractFlags flags) {
_cleanup_free_ char *s = NULL;
diff --git a/src/basic/glob-util.c b/src/basic/glob-util.c
index 112c6392e5..0bfbcb1d37 100644
--- a/src/basic/glob-util.c
+++ b/src/basic/glob-util.c
@@ -22,6 +22,7 @@
#include <glob.h>
#include "glob-util.h"
+#include "string-util.h"
#include "strv.h"
#include "util.h"
diff --git a/src/basic/glob-util.h b/src/basic/glob-util.h
index 8817df14b4..793adf4a6c 100644
--- a/src/basic/glob-util.h
+++ b/src/basic/glob-util.h
@@ -24,7 +24,7 @@
#include <string.h>
#include "macro.h"
-#include "util.h"
+#include "string-util.h"
int glob_exists(const char *path);
int glob_extend(char ***strv, const char *path);
diff --git a/src/basic/macro.h b/src/basic/macro.h
index daa7c416f7..5088e6720d 100644
--- a/src/basic/macro.h
+++ b/src/basic/macro.h
@@ -334,21 +334,6 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) {
_found; \
})
-/* Return a nulstr for a standard cascade of configuration directories,
- * suitable to pass to conf_files_list_nulstr or config_parse_many. */
-#define CONF_DIRS_NULSTR(n) \
- "/etc/" n ".d\0" \
- "/run/" n ".d\0" \
- "/usr/local/lib/" n ".d\0" \
- "/usr/lib/" n ".d\0" \
- CONF_DIR_SPLIT_USR(n)
-
-#ifdef HAVE_SPLIT_USR
-#define CONF_DIR_SPLIT_USR(n) "/lib/" n ".d\0"
-#else
-#define CONF_DIR_SPLIT_USR(n)
-#endif
-
/* Define C11 thread_local attribute even on older gcc compiler
* version */
#ifndef thread_local
diff --git a/src/basic/replace-var.c b/src/basic/replace-var.c
index 18b49a9227..bf757cbc48 100644
--- a/src/basic/replace-var.c
+++ b/src/basic/replace-var.c
@@ -23,9 +23,9 @@
#include "alloc-util.h"
#include "macro.h"
-#include "util.h"
#include "replace-var.h"
-#include "def.h"
+#include "string-util.h"
+#include "util.h"
/*
* Generic infrastructure for replacing @FOO@ style variables in
diff --git a/src/basic/string-util.c b/src/basic/string-util.c
index c3be576816..6006767daa 100644
--- a/src/basic/string-util.c
+++ b/src/basic/string-util.c
@@ -21,9 +21,9 @@
#include "alloc-util.h"
#include "gunicode.h"
+#include "string-util.h"
#include "utf8.h"
#include "util.h"
-#include "string-util.h"
int strcmp_ptr(const char *a, const char *b) {
diff --git a/src/basic/string-util.h b/src/basic/string-util.h
index 15244b8184..54f9d3058c 100644
--- a/src/basic/string-util.h
+++ b/src/basic/string-util.h
@@ -26,6 +26,18 @@
#include "macro.h"
+/* What is interpreted as whitespace? */
+#define WHITESPACE " \t\n\r"
+#define NEWLINE "\n\r"
+#define QUOTES "\"\'"
+#define COMMENTS "#;"
+#define GLOB_CHARS "*?["
+#define DIGITS "0123456789"
+#define LOWERCASE_LETTERS "abcdefghijklmnopqrstuvwxyz"
+#define UPPERCASE_LETTERS "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+#define LETTERS LOWERCASE_LETTERS UPPERCASE_LETTERS
+#define ALPHANUMERICAL LETTERS DIGITS
+
#define streq(a,b) (strcmp((a),(b)) == 0)
#define strneq(a, b, n) (strncmp((a), (b), (n)) == 0)
#define strcaseeq(a,b) (strcasecmp((a),(b)) == 0)
diff --git a/src/basic/util.h b/src/basic/util.h
index a8fba372d1..d9d2f72b75 100644
--- a/src/basic/util.h
+++ b/src/basic/util.h
@@ -44,13 +44,6 @@
#include "missing.h"
#include "time-util.h"
-/* What is interpreted as whitespace? */
-#define WHITESPACE " \t\n\r"
-#define NEWLINE "\n\r"
-#define QUOTES "\"\'"
-#define COMMENTS "#;"
-#define GLOB_CHARS "*?["
-
size_t page_size(void) _pure_;
#define PAGE_ALIGN(l) ALIGN_TO((l), page_size())
diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c
index 8e63153c92..594c9ebe43 100644
--- a/src/binfmt/binfmt.c
+++ b/src/binfmt/binfmt.c
@@ -29,6 +29,7 @@
#include "alloc-util.h"
#include "conf-files.h"
+#include "def.h"
#include "fd-util.h"
#include "fileio.h"
#include "log.h"
diff --git a/src/bootchart/bootchart.c b/src/bootchart/bootchart.c
index 6723fa5098..852febb225 100644
--- a/src/bootchart/bootchart.c
+++ b/src/bootchart/bootchart.c
@@ -51,6 +51,7 @@
#include "alloc-util.h"
#include "bootchart.h"
#include "conf-parser.h"
+#include "def.h"
#include "fd-util.h"
#include "fileio.h"
#include "io-util.h"
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
index dc69bb8679..6326f902e8 100644
--- a/src/journal-remote/journal-remote.c
+++ b/src/journal-remote/journal-remote.c
@@ -37,6 +37,7 @@
#include "alloc-util.h"
#include "conf-parser.h"
+#include "def.h"
#include "escape.h"
#include "fd-util.h"
#include "fileio.h"
diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c
index 7d274d2fc9..42d14dc7c4 100644
--- a/src/journal-remote/journal-upload.c
+++ b/src/journal-remote/journal-upload.c
@@ -29,6 +29,7 @@
#include "alloc-util.h"
#include "conf-parser.h"
+#include "def.h"
#include "fd-util.h"
#include "fileio.h"
#include "formats-util.h"
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index 299b0a848f..3fd25d1af4 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -1473,10 +1473,10 @@ static int dispatch_notify_event(sd_event_source *es, int fd, uint32_t revents,
}
/* The $NOTIFY_SOCKET is writable again, now send exactly one
- * message on it. Either it's the initial READY=1 event or an
- * stdout stream event. If there's nothing to write anymore,
- * turn our event source off. The next time there's something
- * to send it will be turned on again. */
+ * message on it. Either it's the wtachdog event, the initial
+ * READY=1 event or an stdout stream event. If there's nothing
+ * to write anymore, turn our event source off. The next time
+ * there's something to send it will be turned on again. */
if (!s->sent_notify_ready) {
static const char p[] =
@@ -1495,12 +1495,30 @@ static int dispatch_notify_event(sd_event_source *es, int fd, uint32_t revents,
s->sent_notify_ready = true;
log_debug("Sent READY=1 notification.");
+ } else if (s->send_watchdog) {
+
+ static const char p[] =
+ "WATCHDOG=1";
+
+ ssize_t l;
+
+ l = send(s->notify_fd, p, strlen(p), MSG_DONTWAIT);
+ if (l < 0) {
+ if (errno == EAGAIN)
+ return 0;
+
+ return log_error_errno(errno, "Failed to send WATCHDOG=1 notification message: %m");
+ }
+
+ s->send_watchdog = false;
+ log_debug("Sent WATCHDOG=1 notification.");
+
} else if (s->stdout_streams_notify_queue)
/* Dispatch one stream notification event */
stdout_stream_send_notify(s->stdout_streams_notify_queue);
/* Leave us enabled if there's still more to to do. */
- if (s->stdout_streams_notify_queue)
+ if (s->send_watchdog || s->stdout_streams_notify_queue)
return 0;
/* There was nothing to do anymore, let's turn ourselves off. */
@@ -1511,6 +1529,29 @@ static int dispatch_notify_event(sd_event_source *es, int fd, uint32_t revents,
return 0;
}
+static int dispatch_watchdog(sd_event_source *es, uint64_t usec, void *userdata) {
+ Server *s = userdata;
+ int r;
+
+ assert(s);
+
+ s->send_watchdog = true;
+
+ r = sd_event_source_set_enabled(s->notify_event_source, SD_EVENT_ON);
+ if (r < 0)
+ log_warning_errno(r, "Failed to turn on notify event source: %m");
+
+ r = sd_event_source_set_time(s->watchdog_event_source, usec + s->watchdog_usec / 2);
+ if (r < 0)
+ return log_error_errno(r, "Failed to restart watchdog event source: %m");
+
+ r = sd_event_source_set_enabled(s->watchdog_event_source, SD_EVENT_ON);
+ if (r < 0)
+ return log_error_errno(r, "Failed to enable watchdog event source: %m");
+
+ return 0;
+}
+
static int server_connect_notify(Server *s) {
union sockaddr_union sa = {
.un.sun_family = AF_UNIX,
@@ -1573,6 +1614,14 @@ static int server_connect_notify(Server *s) {
if (r < 0)
return log_error_errno(r, "Failed to watch notification socket: %m");
+ if (sd_watchdog_enabled(false, &s->watchdog_usec) > 0) {
+ s->send_watchdog = true;
+
+ r = sd_event_add_time(s->event, &s->watchdog_event_source, CLOCK_MONOTONIC, now(CLOCK_MONOTONIC) + s->watchdog_usec/2, s->watchdog_usec*3/4, dispatch_watchdog, s);
+ if (r < 0)
+ return log_error_errno(r, "Failed to add watchdog time event: %m");
+ }
+
/* This should fire pretty soon, which we'll use to send the
* READY=1 event. */
@@ -1591,6 +1640,8 @@ int server_init(Server *s) {
s->compress = true;
s->seal = true;
+ s->watchdog_usec = USEC_INFINITY;
+
s->sync_interval_usec = DEFAULT_SYNC_INTERVAL_USEC;
s->sync_scheduled = false;
@@ -1808,6 +1859,7 @@ void server_done(Server *s) {
sd_event_source_unref(s->sigint_event_source);
sd_event_source_unref(s->hostname_event_source);
sd_event_source_unref(s->notify_event_source);
+ sd_event_source_unref(s->watchdog_event_source);
sd_event_unref(s->event);
safe_close(s->syslog_fd);
diff --git a/src/journal/journald-server.h b/src/journal/journald-server.h
index 170602ea16..03a61bd2ed 100644
--- a/src/journal/journald-server.h
+++ b/src/journal/journald-server.h
@@ -74,6 +74,7 @@ struct Server {
sd_event_source *sigint_event_source;
sd_event_source *hostname_event_source;
sd_event_source *notify_event_source;
+ sd_event_source *watchdog_event_source;
JournalFile *runtime_journal;
JournalFile *system_journal;
@@ -130,14 +131,14 @@ struct Server {
MMapCache *mmap;
- bool dev_kmsg_readable;
+ struct udev *udev;
uint64_t *kernel_seqnum;
+ bool dev_kmsg_readable:1;
- struct udev *udev;
-
- bool sent_notify_ready;
- bool sync_scheduled;
+ bool send_watchdog:1;
+ bool sent_notify_ready:1;
+ bool sync_scheduled:1;
char machine_id_field[sizeof("_MACHINE_ID=") + 32];
char boot_id_field[sizeof("_BOOT_ID=") + 32];
@@ -145,6 +146,8 @@ struct Server {
/* Cached cgroup root, so that we don't have to query that all the time */
char *cgroup_root;
+
+ usec_t watchdog_usec;
};
#define SERVER_MACHINE_ID(s) ((s)->machine_id_field + strlen("_MACHINE_ID="))
diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c
index c850538d74..42dd15fc15 100644
--- a/src/libsystemd-network/sd-dhcp-lease.c
+++ b/src/libsystemd-network/sd-dhcp-lease.c
@@ -32,11 +32,12 @@
#include "dns-domain.h"
#include "fd-util.h"
#include "fileio.h"
+#include "hexdecoct.h"
#include "hostname-util.h"
#include "in-addr-util.h"
#include "network-internal.h"
-#include "hexdecoct.h"
#include "parse-util.h"
+#include "string-util.h"
#include "unaligned.h"
int sd_dhcp_lease_get_address(sd_dhcp_lease *lease, struct in_addr *addr) {
diff --git a/src/libsystemd/sd-daemon/sd-daemon.c b/src/libsystemd/sd-daemon/sd-daemon.c
index 27045e25d0..a48fa05908 100644
--- a/src/libsystemd/sd-daemon/sd-daemon.c
+++ b/src/libsystemd/sd-daemon/sd-daemon.c
@@ -586,7 +586,7 @@ _public_ int sd_watchdog_enabled(int unset_environment, uint64_t *usec) {
r = safe_atou64(s, &u);
if (r < 0)
goto finish;
- if (u <= 0) {
+ if (u <= 0 || u >= USEC_INFINITY) {
r = -EINVAL;
goto finish;
}
diff --git a/src/login/logind.c b/src/login/logind.c
index 4b8c834269..d1e2ea2489 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -31,6 +31,7 @@
#include "bus-error.h"
#include "bus-util.h"
#include "conf-parser.h"
+#include "def.h"
#include "dirent-util.h"
#include "fd-util.h"
#include "formats-util.h"
diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c
index 830ca7b89d..b90c50719f 100644
--- a/src/modules-load/modules-load.c
+++ b/src/modules-load/modules-load.c
@@ -27,6 +27,7 @@
#include <sys/stat.h>
#include "conf-files.h"
+#include "def.h"
#include "fd-util.h"
#include "fileio.h"
#include "log.h"
diff --git a/src/resolve/resolved-conf.c b/src/resolve/resolved-conf.c
index c9919ced67..42e3be3168 100644
--- a/src/resolve/resolved-conf.c
+++ b/src/resolve/resolved-conf.c
@@ -21,6 +21,7 @@
#include "alloc-util.h"
#include "conf-parser.h"
+#include "def.h"
#include "extract-word.h"
#include "parse-util.h"
#include "resolved-conf.h"
diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c
index bbbb3460d4..102c5cc992 100644
--- a/src/shared/sleep-config.c
+++ b/src/shared/sleep-config.c
@@ -23,14 +23,15 @@
#include "alloc-util.h"
#include "conf-parser.h"
+#include "def.h"
#include "fd-util.h"
#include "fileio.h"
#include "log.h"
+#include "parse-util.h"
#include "sleep-config.h"
#include "string-util.h"
#include "strv.h"
#include "util.h"
-#include "parse-util.h"
#define USE(x, y) do{ (x) = (y); (y) = NULL; } while(0)
diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c
index 5e15dfba53..24cfe58cd6 100644
--- a/src/sysctl/sysctl.c
+++ b/src/sysctl/sysctl.c
@@ -28,6 +28,7 @@
#include <string.h>
#include "conf-files.h"
+#include "def.h"
#include "fd-util.h"
#include "fileio.h"
#include "hashmap.h"
diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c
index 36d310b4c4..9a1c88d08e 100644
--- a/src/sysusers/sysusers.c
+++ b/src/sysusers/sysusers.c
@@ -29,6 +29,8 @@
#include "alloc-util.h"
#include "conf-files.h"
#include "copy.h"
+#include "def.h"
+#include "fd-util.h"
#include "fileio-label.h"
#include "formats-util.h"
#include "hashmap.h"
@@ -39,10 +41,9 @@
#include "string-util.h"
#include "strv.h"
#include "uid-range.h"
+#include "user-util.h"
#include "utf8.h"
#include "util.h"
-#include "fd-util.h"
-#include "user-util.h"
typedef enum ItemType {
ADD_USER = 'u',
diff --git a/src/timesync/timesyncd-conf.c b/src/timesync/timesyncd-conf.c
index be651fc636..001a0f4d41 100644
--- a/src/timesync/timesyncd-conf.c
+++ b/src/timesync/timesyncd-conf.c
@@ -20,11 +20,12 @@
***/
#include "alloc-util.h"
+#include "def.h"
+#include "extract-word.h"
#include "string-util.h"
+#include "timesyncd-conf.h"
#include "timesyncd-manager.h"
#include "timesyncd-server.h"
-#include "timesyncd-conf.h"
-#include "extract-word.h"
int manager_parse_server_string(Manager *m, ServerType type, const char *string) {
ServerName *first;
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 45335425ce..ffae91a3ca 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -45,6 +45,7 @@
#include "chattr-util.h"
#include "conf-files.h"
#include "copy.h"
+#include "def.h"
#include "escape.h"
#include "fd-util.h"
#include "fileio.h"
diff --git a/units/systemd-journald.service.in b/units/systemd-journald.service.in
index 2552102bfc..41bfde5be3 100644
--- a/units/systemd-journald.service.in
+++ b/units/systemd-journald.service.in
@@ -22,6 +22,7 @@ RestartSec=0
NotifyAccess=all
StandardOutput=null
CapabilityBoundingSet=CAP_SYS_ADMIN CAP_DAC_OVERRIDE CAP_SYS_PTRACE CAP_SYSLOG CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_CHOWN CAP_DAC_READ_SEARCH CAP_FOWNER CAP_SETUID CAP_SETGID CAP_MAC_OVERRIDE
+WatchdogSec=3min
FileDescriptorStoreMax=1024
# Increase the default a bit in order to allow many simultaneous