chiark / gitweb /
build-sys: make test output a bit nicer
[elogind.git] / src / journal / journald-server.c
index a4fa394bc70629ccac30c34db543f782e994ecf4..a3bacdab66a68ec930d6903f9ec0166872d79664 100644 (file)
@@ -135,11 +135,11 @@ static uint64_t available_space(Server *s, bool verbose) {
         for (;;) {
                 struct stat st;
                 struct dirent *de;
-                union dirent_storage buf;
 
-                r = readdir_r(d, &buf.de, &de);
-                if (r != 0)
-                        break;
+                errno = 0;
+                de = readdir(d);
+                if (!de && errno != 0)
+                        return 0;
 
                 if (!de)
                         break;
@@ -622,7 +622,7 @@ static void dispatch_message_real(
                 }
 #endif
 
-                r = cg_pid_get_path_shifted(ucred->pid, NULL, &c);
+                r = cg_pid_get_path_shifted(ucred->pid, s->cgroup_root, &c);
                 if (r >= 0) {
                         char *session = NULL;
 
@@ -743,7 +743,7 @@ static void dispatch_message_real(
                 }
 #endif
 
-                r = cg_pid_get_path_shifted(object_pid, NULL, &c);
+                r = cg_pid_get_path_shifted(object_pid, s->cgroup_root, &c);
                 if (r >= 0) {
                         x = strappenda("OBJECT_SYSTEMD_CGROUP=", c);
                         IOVEC_SET_STRING(iovec[n++], x);
@@ -878,7 +878,7 @@ void server_dispatch_message(
         if (!ucred)
                 goto finish;
 
-        r = cg_pid_get_path_shifted(ucred->pid, NULL, &path);
+        r = cg_pid_get_path_shifted(ucred->pid, s->cgroup_root, &path);
         if (r < 0)
                 goto finish;
 
@@ -1243,7 +1243,7 @@ static int dispatch_sigterm(sd_event_source *es, const struct signalfd_siginfo *
 
         log_info("Received SIG%s", signal_to_string(si->ssi_signo));
 
-        sd_event_request_quit(s->event);
+        sd_event_exit(s->event, 0);
         return 0;
 }
 
@@ -1563,6 +1563,10 @@ int server_init(Server *s) {
         if (!s->rate_limit)
                 return -ENOMEM;
 
+        r = cg_get_root_path(&s->cgroup_root);
+        if (r < 0)
+                return r;
+
         server_cache_hostname(s);
         server_cache_boot_id(s);
         server_cache_machine_id(s);
@@ -1643,6 +1647,7 @@ void server_done(Server *s) {
 
         free(s->buffer);
         free(s->tty_path);
+        free(s->cgroup_root);
 
         if (s->mmap)
                 mmap_cache_unref(s->mmap);