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.
This commit is contained in:
Christian Hergert
2016-10-15 10:26:36 -07:00
parent a760a6ca10
commit 392aa177b6

View File

@ -714,15 +714,20 @@ static gboolean
sp_capture_writer_flush_end_time (SpCaptureWriter *self) sp_capture_writer_flush_end_time (SpCaptureWriter *self)
{ {
gint64 end_time = SP_CAPTURE_CURRENT_TIME; gint64 end_time = SP_CAPTURE_CURRENT_TIME;
ssize_t ret;
g_assert (self != NULL); g_assert (self != NULL);
/* This field is opportunistic, so a failure is okay. */ /* This field is opportunistic, so a failure is okay. */
pwrite (self->fd, again:
&end_time, ret = pwrite (self->fd,
sizeof (end_time), &end_time,
G_STRUCT_OFFSET (SpCaptureFileHeader, end_time)); sizeof (end_time),
G_STRUCT_OFFSET (SpCaptureFileHeader, end_time));
if (ret < 0 && errno == EAGAIN)
goto again;
return TRUE; return TRUE;
} }