Enabled by default for test purposes. --- src/journal/journal-send.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
diff --git a/src/journal/journal-send.c b/src/journal/journal-send.c index 281e154..9c4acc2 100644 --- a/src/journal/journal-send.c +++ b/src/journal/journal-send.c @@ -196,6 +196,41 @@ finish: return r; } +static int write_snippet(const struct iovec *iov, int n) { + + static const char dir[] = "/dev/shm"; + char path[PATH_MAX]; /* FIXME */ + struct timespec ts; + struct stat st; + int fd; + int r; + + if (stat(dir, &st) < 0 || !S_ISDIR(st.st_mode)) + return -1; + + do { + clock_gettime(CLOCK_REALTIME, &ts); + snprintf(path, PATH_MAX, "%s/journal-snippet.%lu.%lu", dir, ts.tv_sec, ts.tv_nsec); /* FIXME */ + + fd = open(path, O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); + + } while (fd < 0 && errno == EEXIST); + + if (fd < 0) + return -errno; + + r = writev(fd, iov, n); + if (r < 0) + r = -errno; + else + r = 1; + + close_nointr_nofail(fd); + + return r; +} + + _public_ int sd_journal_sendv(const struct iovec *iov, int n) { PROTECT_ERRNO; int fd, buffer_fd; @@ -289,6 +324,10 @@ _public_ int sd_journal_sendv(const struct iovec *iov, int n) { IOVEC_SET_STRING(w[j++], "\n"); } + /* Try to drop journald snippet for delayed processing */ + if (write_snippet(w, j) > 0) + return 0; + fd = journal_fd(); if (_unlikely_(fd < 0)) return fd; -- 1.8.4.rc3 _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel