[glib] Handle EINTR when sending logs to the journal



commit ad285d9bd25419b5a4672cd4a6be77896b642992
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Jul 25 10:25:40 2016 -0400

    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 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/glib/gmessages.c b/glib/gmessages.c
index c81970c..9e192f7 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;
+
+  if (errno == EINTR)
+    goto retry2;
 
-  return 0;
+  return -1;
 }
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]