rtpsession: Take session lock when creating stats
authorMiguel París Díaz <mparisdiaz@gmail.com>
Thu, 5 May 2016 12:18:21 +0000 (14:18 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Fri, 6 May 2016 06:24:22 +0000 (09:24 +0300)
The access to the session hash table must happen while the session lock is
taken, otherwise another thread might modify the hash table while we're
creating the stats.

https://bugzilla.gnome.org/show_bug.cgi?id=766025

gst/rtpmanager/rtpsession.c

index 3c26e34..e530c95 100644 (file)
@@ -749,10 +749,12 @@ rtp_session_create_stats (RTPSession * sess)
       "sent-nack-count", G_TYPE_UINT, sess->stats.nacks_sent,
       "recv-nack-count", G_TYPE_UINT, sess->stats.nacks_received, NULL);
 
+  RTP_SESSION_LOCK (sess);
   size = g_hash_table_size (sess->ssrcs[sess->mask_idx]);
   source_stats = g_value_array_new (size);
   g_hash_table_foreach (sess->ssrcs[sess->mask_idx],
       (GHFunc) create_source_stats, source_stats);
+  RTP_SESSION_UNLOCK (sess);
 
   g_value_init (&source_stats_v, G_TYPE_VALUE_ARRAY);
   g_value_take_boxed (&source_stats_v, source_stats);