summaryrefslogtreecommitdiff
path: root/agent/component.c
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2014-08-08 11:30:43 +0100
committerOlivier CrĂȘte <olivier.crete@collabora.com>2014-08-21 14:33:11 -0400
commit02a3786fa6340e67f7b0829bac70a609e9ab1165 (patch)
tree03e3a48f07b420ee76dd3c4a41c3789f89d17c24 /agent/component.c
parent8abc39749c081ec5b9b8f7743ed5826e3b6bc6b7 (diff)
downloadlibnice-02a3786fa6340e67f7b0829bac70a609e9ab1165.tar.gz
agent: Factor out common clean up code in Component
This introduces no functional changes.
Diffstat (limited to 'agent/component.c')
-rw-r--r--agent/component.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/agent/component.c b/agent/component.c
index 57282ae..b512025 100644
--- a/agent/component.c
+++ b/agent/component.c
@@ -193,6 +193,18 @@ component_clean_turn_servers (Component *cmp)
}
}
+static void
+component_clear_selected_pair (Component *component)
+{
+ if (component->selected_pair.keepalive.tick_source != NULL) {
+ g_source_destroy (component->selected_pair.keepalive.tick_source);
+ g_source_unref (component->selected_pair.keepalive.tick_source);
+ component->selected_pair.keepalive.tick_source = NULL;
+ }
+
+ memset (&component->selected_pair, 0, sizeof(CandidatePair));
+}
+
void
component_free (Component *cmp)
{
@@ -369,12 +381,6 @@ void component_update_selected_pair (Component *component, const CandidatePair *
G_GUINT64_FORMAT ").", component->id, pair->local->foundation,
pair->remote->foundation, pair->priority);
- if (component->selected_pair.keepalive.tick_source != NULL) {
- g_source_destroy (component->selected_pair.keepalive.tick_source);
- g_source_unref (component->selected_pair.keepalive.tick_source);
- component->selected_pair.keepalive.tick_source = NULL;
- }
-
if (component->selected_pair.local &&
component->selected_pair.local == component->turn_candidate) {
refresh_prune_candidate (component->agent, component->turn_candidate);
@@ -383,7 +389,7 @@ void component_update_selected_pair (Component *component, const CandidatePair *
component->turn_candidate = NULL;
}
- memset (&component->selected_pair, 0, sizeof(CandidatePair));
+ component_clear_selected_pair (component);
component->selected_pair.local = pair->local;
component->selected_pair.remote = pair->remote;
@@ -460,13 +466,8 @@ component_set_selected_remote_candidate (NiceAgent *agent, Component *component,
agent_signal_new_remote_candidate (agent, remote);
}
- if (component->selected_pair.keepalive.tick_source != NULL) {
- g_source_destroy (component->selected_pair.keepalive.tick_source);
- g_source_unref (component->selected_pair.keepalive.tick_source);
- component->selected_pair.keepalive.tick_source = NULL;
- }
+ component_clear_selected_pair (component);
- memset (&component->selected_pair, 0, sizeof(CandidatePair));
component->selected_pair.local = local;
component->selected_pair.remote = remote;
component->selected_pair.priority = priority;