diff options
| author | Lennart Poettering <lennart@poettering.net> | 2017-12-11 20:01:55 +0100 |
|---|---|---|
| committer | Lennart Poettering <lennart@poettering.net> | 2017-12-14 10:46:19 +0100 |
| commit | 35bbbf85e01372cc5091fa5fbf3ca83e262de90d (patch) | |
| tree | adc0812fa0008ba8d411a68bb7a8c0e345f1df1b /src/basic/process-util.c | |
| parent | 0d5366733428b657e1b5b7700b461e878e00b578 (diff) | |
| download | systemd-35bbbf85e01372cc5091fa5fbf3ca83e262de90d.tar.gz | |
basic: turn off stdio locking for a couple of helper calls
These helper calls are potentially called often, and allocate FILE*
objects internally for a very short period of time, let's turn off
locking for them too.
Diffstat (limited to 'src/basic/process-util.c')
| -rw-r--r-- | src/basic/process-util.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/basic/process-util.c b/src/basic/process-util.c index 5f001494f0..32c3c951a1 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -26,6 +26,7 @@ #include <signal.h> #include <stdbool.h> #include <stdio.h> +#include <stdio_ext.h> #include <stdlib.h> #include <string.h> #include <sys/mman.h> @@ -130,6 +131,8 @@ int get_process_cmdline(pid_t pid, size_t max_length, bool comm_fallback, char * return -errno; } + (void) __fsetlocking(f, FSETLOCKING_BYCALLER); + if (max_length == 1) { /* If there's only room for one byte, return the empty string */ @@ -406,6 +409,8 @@ int is_kernel_thread(pid_t pid) { return -errno; } + (void) __fsetlocking(f, FSETLOCKING_BYCALLER); + count = fread(&c, 1, 1, f); eof = feof(f); fclose(f); @@ -487,6 +492,8 @@ static int get_process_id(pid_t pid, const char *field, uid_t *uid) { return -errno; } + (void) __fsetlocking(f, FSETLOCKING_BYCALLER); + FOREACH_LINE(line, f, return -errno) { char *l; @@ -565,6 +572,8 @@ int get_process_environ(pid_t pid, char **env) { return -errno; } + (void) __fsetlocking(f, FSETLOCKING_BYCALLER); + while ((c = fgetc(f)) != EOF) { if (!GREEDY_REALLOC(outcome, allocated, sz + 5)) return -ENOMEM; @@ -749,6 +758,8 @@ int getenv_for_pid(pid_t pid, const char *field, char **_value) { return -errno; } + (void) __fsetlocking(f, FSETLOCKING_BYCALLER); + l = strlen(field); r = 0; |
