From 91bf3b3e124575f6f647bff29766e9d992f55b32 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 11 Dec 2013 22:17:15 +0100 Subject: [PATCH] journal: don't go belly up when an stdout/stderr client terminates the connection --- src/journal/journald-stream.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c index e887f01a491..b2291a260f3 100644 --- a/src/journal/journald-stream.c +++ b/src/journal/journald-stream.c @@ -293,7 +293,8 @@ static int stdout_stream_process(sd_event_source *es, int fd, uint32_t revents, if ((revents|EPOLLIN|EPOLLHUP) != (EPOLLIN|EPOLLHUP)) { log_error("Got invalid event from epoll for stdout stream: %"PRIx32, revents); - return -EIO; + r = -EIO; + goto terminate; } l = read(s->fd, s->buffer+s->length, sizeof(s->buffer)-1-s->length); @@ -303,25 +304,23 @@ static int stdout_stream_process(sd_event_source *es, int fd, uint32_t revents, return 0; log_warning("Failed to read from stream: %m"); - goto fail; + r = -errno; + goto terminate; } if (l == 0) { r = stdout_stream_scan(s, true); - if (r < 0) - goto fail; - - return 0; + goto terminate; } s->length += l; r = stdout_stream_scan(s, false); if (r < 0) - goto fail; + goto terminate; return 1; -fail: +terminate: stdout_stream_free(s); return 0; }