Commit 375cde8a authored by Olivier Crête's avatar Olivier Crête

agent: Avoid leaking UPnP mappings between streams

Clean up the UPnP mappings of each stream when closing it
parent 838c5cb5
......@@ -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);
......
......@@ -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
......
......@@ -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;
......
......@@ -248,7 +248,7 @@ AC_SUBST(gstplugin010dir)
AM_CONDITIONAL(WITH_GSTREAMER, test "$with_gstreamer" = yes)
AM_CONDITIONAL(WITH_GSTREAMER010, test "$with_gstreamer010" = yes)
GUPNP_IGD_REQUIRED=0.1.2
GUPNP_IGD_REQUIRED=0.2.4
AC_ARG_ENABLE([gupnp],
AS_HELP_STRING([--disable-gupnp],[Disable GUPnP IGD support]),
......
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