diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2014-11-14 10:06:21 +0000 |
---|---|---|
committer | Philip Withnall <philip.withnall@collabora.co.uk> | 2014-11-14 10:07:02 +0000 |
commit | 20a5868eb8b3d30a86b0603b56b49e1f70736868 (patch) | |
tree | b84f30e582e2c327272072599b2dcf1dd1b53c7e | |
parent | 28d1c100c1bdfa123bf8a64706640ee8dbd18247 (diff) |
agent: Add debug output for lifetime of Components and Streams
-rw-r--r-- | agent/component.c | 13 | ||||
-rw-r--r-- | agent/stream.c | 13 |
2 files changed, 26 insertions, 0 deletions
diff --git a/agent/component.c b/agent/component.c index 8a1d064..1a1f84a 100644 --- a/agent/component.c +++ b/agent/component.c @@ -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; @@ -318,6 +327,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); } /* diff --git a/agent/stream.c b/agent/stream.c index 2ce1668..09f79b5 100644 --- a/agent/stream.c +++ b/agent/stream.c @@ -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 * |