summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/journald-server.c11
-rw-r--r--src/journal/journald-server.h3
-rw-r--r--src/journal/sd-journal.c2
3 files changed, 12 insertions, 4 deletions
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index a4fa394bc..0f67fb8d5 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -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;
@@ -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);
diff --git a/src/journal/journald-server.h b/src/journal/journald-server.h
index 86c4be4ba..2a81061f2 100644
--- a/src/journal/journald-server.h
+++ b/src/journal/journald-server.h
@@ -136,6 +136,9 @@ typedef struct Server {
char machine_id_field[sizeof("_MACHINE_ID=") + 32];
char boot_id_field[sizeof("_BOOT_ID=") + 32];
char *hostname_field;
+
+ /* Cached cgroup root, so that we don't have to query that all the time */
+ char *cgroup_root;
} Server;
#define N_IOVEC_META_FIELDS 20
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index dda9351da..bb116df04 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -1616,8 +1616,8 @@ static int add_current_paths(sd_journal *j) {
* treat them as fatal. */
HASHMAP_FOREACH(f, j->files, i) {
- int r;
_cleanup_free_ char *dir;
+ int r;
dir = dirname_malloc(f->path);
if (!dir)