summaryrefslogtreecommitdiff
path: root/src/journal/journald-server.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-01-06 00:30:25 +0100
committerLennart Poettering <lennart@poettering.net>2015-01-06 03:16:39 +0100
commit13790add4bf648fed816361794d8277a75253410 (patch)
treeee47acce1e01571de313b6db70b365f88aafdfbf /src/journal/journald-server.c
parenta354329f724d6ce913d2ccffb2be8f3327a67faa (diff)
journald: allow restarting journald without losing stream connections
Making use of the fd storage capability of the previous commit, allow restarting journald by serilizing stream state to /run, and pushing open fds to PID 1.
Diffstat (limited to 'src/journal/journald-server.c')
-rw-r--r--src/journal/journald-server.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index 4613550039..e0a078ee33 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -1182,6 +1182,10 @@ int server_process_datagram(sd_event_source *es, int fd, uint32_t revents, void
log_error_errno(errno, "recvmsg() failed: %m");
return -errno;
}
+ if (n == 0) {
+ log_error("Got EOF on socket.");
+ return -ECONNRESET;
+ }
for (cmsg = CMSG_FIRSTHDR(&msghdr); cmsg; cmsg = CMSG_NXTHDR(&msghdr, cmsg)) {
@@ -1462,6 +1466,7 @@ static int server_open_hostname(Server *s) {
}
int server_init(Server *s) {
+ _cleanup_fdset_free_ FDSet *fds = NULL;
int n, r, fd;
assert(s);
@@ -1558,26 +1563,33 @@ int server_init(Server *s) {
s->audit_fd = fd;
} else {
- log_warning("Unknown socket passed as file descriptor %d, ignoring.", fd);
- /* Let's close the fd, better be safe than
- sorry. The fd might reference some resource
- that we really want to release if we don't
- make use of it. */
+ if (!fds) {
+ fds = fdset_new();
+ if (!fds)
+ return log_oom();
+ }
- safe_close(fd);
+ r = fdset_put(fds, fd);
+ if (r < 0)
+ return log_oom();
}
}
- r = server_open_syslog_socket(s);
+ r = server_open_stdout_socket(s, fds);
if (r < 0)
return r;
- r = server_open_native_socket(s);
+ if (fdset_size(fds) > 0) {
+ log_warning("%u unknown file descriptors passed, closing.", fdset_size(fds));
+ fds = fdset_free(fds);
+ }
+
+ r = server_open_syslog_socket(s);
if (r < 0)
return r;
- r = server_open_stdout_socket(s);
+ r = server_open_native_socket(s);
if (r < 0)
return r;