Commit a0b07e1d authored by Philip Withnall's avatar Philip Withnall

agent: Add debug output for lifetime of Components and Streams

parent 56c8a14d
......@@ -42,6 +42,11 @@
* @brief ICE component functions
*/
/* Simple tracking for the number of alive components. These must be accessed
* atomically. */
static volatile unsigned int n_components_created = 0;
static volatile unsigned int n_components_destroyed = 0;
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
......@@ -121,6 +126,10 @@ component_new (guint id, NiceAgent *agent, Stream *stream)
{
Component *component;
g_atomic_int_inc (&n_components_created);
nice_debug ("Created NiceComponent (%u created, %u destroyed)",
n_components_created, n_components_destroyed);
component = g_slice_new0 (Component);
component->id = id;
component->state = NICE_COMPONENT_STATE_DISCONNECTED;
......@@ -307,6 +316,10 @@ component_free (Component *cmp)
g_main_context_unref (cmp->own_ctx);
g_slice_free (Component, cmp);
g_atomic_int_inc (&n_components_destroyed);
nice_debug ("Destroyed NiceComponent (%u created, %u destroyed)",
n_components_created, n_components_destroyed);
}
/*
......
......@@ -43,6 +43,11 @@
#include "stream.h"
/* Simple tracking for the number of alive streams. These must be accessed
* atomically. */
static volatile unsigned int n_streams_created = 0;
static volatile unsigned int n_streams_destroyed = 0;
/*
* @file stream.c
* @brief ICE stream functionality
......@@ -54,6 +59,10 @@ stream_new (guint n_components, NiceAgent *agent)
guint n;
Component *component;
g_atomic_int_inc (&n_streams_created);
nice_debug ("Created NiceStream (%u created, %u destroyed)",
n_streams_created, n_streams_destroyed);
stream = g_slice_new0 (Stream);
for (n = 0; n < n_components; n++) {
component = component_new (n + 1, agent, stream);
......@@ -83,6 +92,10 @@ stream_free (Stream *stream)
g_free (stream->name);
g_slist_free_full (stream->components, (GDestroyNotify) component_free);
g_slice_free (Stream, stream);
g_atomic_int_inc (&n_streams_destroyed);
nice_debug ("Destroyed NiceStream (%u created, %u destroyed)",
n_streams_created, n_streams_destroyed);
}
Component *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment