mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
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.
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user