[Nice] [nice/master] Unlock mutex on the locks that matter

Olivier Crete olivier.crete at collabora.co.uk
Wed Nov 5 14:01:08 PST 2008


darcs-hash:20080425200042-3e2dc-84d2a1ba9a2ebec18d8700a15647a586957f4ce4.gz
---
 agent/agent.c     |   24 ++++++++++++++++++------
 agent/discovery.c |    3 ++-
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/agent/agent.c b/agent/agent.c
index e81f9ac..237c8d3 100644
--- a/agent/agent.c
+++ b/agent/agent.c
@@ -555,7 +555,9 @@ nice_agent_set_property (
 
 void agent_signal_gathering_done (NiceAgent *agent)
 {
+  g_mutex_unlock (agent->mutex);
   g_signal_emit (agent, signals[SIGNAL_CANDIDATE_GATHERING_DONE], 0);
+  g_mutex_lock (agent->mutex);
 }
 
 void agent_signal_initial_binding_request_received (NiceAgent *agent, Stream *stream)
@@ -569,20 +571,30 @@ void agent_signal_initial_binding_request_received (NiceAgent *agent, Stream *st
 void agent_signal_new_selected_pair (NiceAgent *agent, guint stream_id, guint component_id, const gchar *local_foundation, const gchar *remote_foundation)
 {
   Component *component;
+  gchar *lf_copy;
+  gchar *rf_copy;
 
   if (!agent_find_component (agent, stream_id, component_id, NULL, &component))
     return;
 
-  g_signal_emit (agent, signals[SIGNAL_NEW_SELECTED_PAIR], 0, 
-		 stream_id, component_id,
-		 local_foundation, remote_foundation);
+  lf_copy = g_strdup (local_foundation);
+  rf_copy = g_strdup (remote_foundation);
+
+  g_mutex_unlock (agent->mutex);
+
+  g_signal_emit (agent, signals[SIGNAL_NEW_SELECTED_PAIR], 0,
+      stream_id, component_id, lf_copy, rf_copy);
+  g_mutex_lock (agent->mutex);
+
+  g_free (lf_copy);
+  g_free (rf_copy);
 }
 
 void agent_signal_new_candidate (NiceAgent *agent, NiceCandidate *candidate)
 {
-  g_signal_emit (agent, signals[SIGNAL_NEW_CANDIDATE], 0, 
-		 candidate->stream_id, 
-		 candidate->component_id, 
+  g_signal_emit (agent, signals[SIGNAL_NEW_CANDIDATE], 0,
+		 candidate->stream_id,
+		 candidate->component_id,
 		 candidate->foundation);
 }
 
diff --git a/agent/discovery.c b/agent/discovery.c
index 2281dd7..dae70ca 100644
--- a/agent/discovery.c
+++ b/agent/discovery.c
@@ -559,9 +559,10 @@ static gboolean priv_discovery_tick_unlocked (gpointer pointer)
   if (not_done == 0) {
     g_debug ("Candidate gathering FINISHED, stopping discovery timer.");
 
-    agent_signal_gathering_done (agent);
     discovery_free (agent);
 
+    agent_signal_gathering_done (agent);
+
     /* note: no pending timers, return FALSE to stop timer */
     return FALSE;
   }
-- 
1.5.6.5




More information about the Nice mailing list