[sysprof] libsysprof-capture: write final frame
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] libsysprof-capture: write final frame
- Date: Sun, 16 Feb 2020 05:02:37 +0000 (UTC)
commit c36420d71641937ef7d39ddbe7e43f4f42e0812b
Author: Christian Hergert <chergert redhat com>
Date: Sat Feb 15 20:49:27 2020 -0700
libsysprof-capture: write final frame
This frame type can be used to communicate with the peer over the mapped
ring buffer to denote that writing is finished and it can free any
resources for the mapping.
src/libsysprof-capture/sysprof-collector.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
---
diff --git a/src/libsysprof-capture/sysprof-collector.c b/src/libsysprof-capture/sysprof-collector.c
index 5694cc9..eac09ca 100644
--- a/src/libsysprof-capture/sysprof-collector.c
+++ b/src/libsysprof-capture/sysprof-collector.c
@@ -184,6 +184,24 @@ request_writer (void)
return g_steal_pointer (&buffer);
}
+static void
+write_final_frame (MappedRingBuffer *ring)
+{
+ SysprofCaptureFrame *fr;
+
+ g_assert (ring != NULL);
+
+ if ((fr = mapped_ring_buffer_allocate (ring, sizeof *fr)))
+ {
+ fr->len = sizeof *fr; /* aligned */
+ fr->type = 0xFF; /* Invalid */
+ fr->cpu = -1;
+ fr->pid = -1;
+ fr->time = SYSPROF_CAPTURE_CURRENT_TIME;
+ mapped_ring_buffer_advance (ring, fr->len);
+ }
+}
+
static void
sysprof_collector_free (gpointer data)
{
@@ -191,7 +209,12 @@ sysprof_collector_free (gpointer data)
if (collector != NULL && collector != COLLECTOR_MAGIC_CREATING)
{
- g_clear_pointer (&collector->buffer, mapped_ring_buffer_unref);
+ if (collector->buffer != NULL)
+ {
+ write_final_frame (collector->buffer);
+ g_clear_pointer (&collector->buffer, mapped_ring_buffer_unref);
+ }
+
g_free (collector);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]