From ad285d9bd25419b5a4672cd4a6be77896b642992 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 25 Jul 2016 10:25:40 -0400 Subject: [PATCH] Handle EINTR when sending logs to the journal Ray pointed out that we might well get interrupted here, and should not loose logs due to that. --- glib/gmessages.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/glib/gmessages.c b/glib/gmessages.c index c81970c12..9e192f770 100644 --- a/glib/gmessages.c +++ b/glib/gmessages.c @@ -1818,9 +1818,13 @@ journal_sendv (struct iovec *iov, mh.msg_iov = iov; mh.msg_iovlen = iovlen; +retry: if (sendmsg (journal_fd, &mh, MSG_NOSIGNAL) >= 0) return 0; + if (errno == EINTR) + goto retry; + if (errno != EMSGSIZE && errno != ENOBUFS) return -1; @@ -1857,9 +1861,14 @@ journal_sendv (struct iovec *iov, mh.msg_controllen = cmsg->cmsg_len; - (void) sendmsg (journal_fd, &mh, MSG_NOSIGNAL); +retry2: + if (sendmsg (journal_fd, &mh, MSG_NOSIGNAL) >= 0) + return 0; - return 0; + if (errno == EINTR) + goto retry2; + + return -1; } /**