[sysprof] writer: use dup()d fd when creating reader
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] writer: use dup()d fd when creating reader
- Date: Fri, 15 Apr 2016 02:25:41 +0000 (UTC)
commit 1b8cfed5c880d1fdc9c0d71412d918b14aebabb5
Author: Christian Hergert <christian hergert me>
Date: Thu Apr 14 19:25:26 2016 -0700
writer: use dup()d fd when creating reader
Readers can share the file-offset in the file-descriptor table, but should
really have their own fd that they can close().
lib/sp-capture-writer.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/lib/sp-capture-writer.c b/lib/sp-capture-writer.c
index 794fa38..b416c57 100644
--- a/lib/sp-capture-writer.c
+++ b/lib/sp-capture-writer.c
@@ -933,10 +933,19 @@ SpCaptureReader *
sp_capture_writer_create_reader (SpCaptureWriter *self,
GError **error)
{
+ int copy;
+
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (self->fd != -1, NULL);
- return sp_capture_reader_new_from_fd (self->fd, error);
+ /*
+ * We don't care about the write position, since the reader
+ * uses positioned reads.
+ */
+ if (-1 == (copy = dup (self->fd)))
+ return NULL;
+
+ return sp_capture_reader_new_from_fd (copy, error);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]