diff options
author | Olivier CrĂȘte <olivier.crete@collabora.com> | 2014-10-01 00:00:30 -0400 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2014-10-09 16:26:07 -0400 |
commit | 375cde8a652f8e367cf875bcb718a6d1abcfb254 (patch) | |
tree | 541a53bb227af0d5199b6367691dfbc593792a1a /agent | |
parent | 838c5cb5a73398e8134a13210714a317abfbcf20 (diff) | |
download | libnice-375cde8a652f8e367cf875bcb718a6d1abcfb254.tar.gz |
agent: Avoid leaking UPnP mappings between streams
Clean up the UPnP mappings of each stream when closing it
Diffstat (limited to 'agent')
-rw-r--r-- | agent/agent-priv.h | 3 | ||||
-rw-r--r-- | agent/agent.c | 21 | ||||
-rw-r--r-- | agent/component.c | 11 |
3 files changed, 32 insertions, 3 deletions
diff --git a/agent/agent-priv.h b/agent/agent-priv.h index c9e5c45..c413bc1 100644 --- a/agent/agent-priv.h +++ b/agent/agent-priv.h @@ -213,6 +213,9 @@ StunUsageIceCompatibility agent_to_ice_compatibility (NiceAgent *agent); StunUsageTurnCompatibility agent_to_turn_compatibility (NiceAgent *agent); NiceTurnSocketCompatibility agent_to_turn_socket_compatibility (NiceAgent *agent); +void agent_remove_local_candidate (NiceAgent *agent, + NiceCandidate *candidate); + void nice_agent_init_stun_agent (NiceAgent *agent, StunAgent *stun_agent); void _priv_set_socket_tos (NiceAgent *agent, NiceSocket *sock, gint tos); diff --git a/agent/agent.c b/agent/agent.c index 1eb2a18..771cbac 100644 --- a/agent/agent.c +++ b/agent/agent.c @@ -2850,6 +2850,9 @@ nice_agent_gather_candidates ( for (i = component->local_candidates; i; i = i->next) { NiceCandidate *candidate = i->data; + + agent_remove_local_candidate (agent, candidate); + nice_candidate_free (candidate); } g_slist_free (component->local_candidates); @@ -2863,6 +2866,24 @@ nice_agent_gather_candidates ( return ret; } +void agent_remove_local_candidate (NiceAgent *agent, NiceCandidate *candidate) +{ +#ifdef HAVE_GUPNP + gchar local_ip[NICE_ADDRESS_STRING_LEN]; + + if (agent->upnp == NULL) + return; + + if (candidate->type != NICE_CANDIDATE_TYPE_HOST) + return; + + nice_address_to_string (&candidate->addr, local_ip); + + gupnp_simple_igd_remove_port_local (GUPNP_SIMPLE_IGD (agent->upnp), "UDP", + local_ip, nice_address_get_port (&candidate->addr)); +#endif +} + static void priv_stop_upnp (NiceAgent *agent) { #ifdef HAVE_GUPNP diff --git a/agent/component.c b/agent/component.c index 539d387..c6a5601 100644 --- a/agent/component.c +++ b/agent/component.c @@ -200,6 +200,7 @@ component_clean_turn_servers (Component *cmp) conn_check_prune_socket (cmp->agent, cmp->stream, cmp, candidate->sockptr); component_detach_socket (cmp, candidate->sockptr); + agent_remove_local_candidate (cmp->agent, candidate); nice_candidate_free (candidate); } cmp->local_candidates = g_slist_delete_link (cmp->local_candidates, i); @@ -235,9 +236,13 @@ component_close (Component *cmp) nice_candidate_free (cmp->turn_candidate), cmp->turn_candidate = NULL; - g_slist_free_full (cmp->local_candidates, - (GDestroyNotify) nice_candidate_free); - cmp->local_candidates = NULL; + while (cmp->local_candidates) { + agent_remove_local_candidate (cmp->agent, cmp->local_candidates->data); + nice_candidate_free (cmp->local_candidates->data); + cmp->local_candidates = g_slist_delete_link (cmp->local_candidates, + cmp->local_candidates); + } + g_slist_free_full (cmp->remote_candidates, (GDestroyNotify) nice_candidate_free); cmp->remote_candidates = NULL; |