[sysprof] capture-writer: handle EAGAIN



commit 392aa177b6c966bee905d0daf69090f2ee9a526d
Author: Christian Hergert <chergert redhat com>
Date:   Sat Oct 15 10:26:36 2016 -0700

    capture-writer: handle EAGAIN
    
    This field is opportunistic, so failure isn't a big deal, but we can at
    least try again in an EAGAIN case. Should also squash a compiler warning
    about unused results.

 lib/sp-capture-writer.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/lib/sp-capture-writer.c b/lib/sp-capture-writer.c
index ef39138..564437d 100644
--- a/lib/sp-capture-writer.c
+++ b/lib/sp-capture-writer.c
@@ -714,15 +714,20 @@ static gboolean
 sp_capture_writer_flush_end_time (SpCaptureWriter *self)
 {
   gint64 end_time = SP_CAPTURE_CURRENT_TIME;
+  ssize_t ret;
 
   g_assert (self != NULL);
 
   /* This field is opportunistic, so a failure is okay. */
 
-  pwrite (self->fd,
-          &end_time,
-          sizeof (end_time),
-          G_STRUCT_OFFSET (SpCaptureFileHeader, end_time));
+again:
+  ret = pwrite (self->fd,
+                &end_time,
+                sizeof (end_time),
+                G_STRUCT_OFFSET (SpCaptureFileHeader, end_time));
+
+  if (ret < 0 && errno == EAGAIN)
+    goto again;
 
   return TRUE;
 }


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