From b2189b848dcdce40abbfad00700b2812d691dfda Mon Sep 17 00:00:00 2001 From: =?utf8?q?Olivier=20Cr=C3=AAte?= Date: Thu, 27 Mar 2014 21:09:15 -0400 Subject: [PATCH] agent: Prevent gather from being called multiple times This can cause odd behaviors as it is not a idempotent function. --- agent/agent.c | 8 +++++++- agent/stream.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/agent/agent.c b/agent/agent.c index 0f48fbc..fe32b27 100644 --- a/agent/agent.c +++ b/agent/agent.c @@ -2123,6 +2123,12 @@ nice_agent_gather_candidates ( return FALSE; } + if (stream->gathering_started) { + /* Stream is already gathering, ignore this call */ + agent_unlock_and_emit (agent); + return TRUE; + } + nice_debug ("Agent %p : In %s mode, starting candidate gathering.", agent, agent->full_mode ? "ICE-FULL" : "ICE-LITE"); @@ -2276,7 +2282,7 @@ nice_agent_gather_candidates ( } stream->gathering = TRUE; - + stream->gathering_started = TRUE; /* Only signal the new candidates after we're sure that the gathering was * succesfful. But before sending gathering-done */ diff --git a/agent/stream.h b/agent/stream.h index 08c39c5..96a478b 100644 --- a/agent/stream.h +++ b/agent/stream.h @@ -72,6 +72,7 @@ struct _Stream gchar remote_ufrag[NICE_STREAM_MAX_UFRAG]; gchar remote_password[NICE_STREAM_MAX_PWD]; gboolean gathering; + gboolean gathering_started; gint tos; }; -- 2.7.4