From 392aa177b6c966bee905d0daf69090f2ee9a526d Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Sat, 15 Oct 2016 10:26:36 -0700 Subject: [PATCH] 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 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/sp-capture-writer.c b/lib/sp-capture-writer.c index ef391388..564437d9 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; }