[Bug 742684] aggregator: Usage of GCond is racy.

GStreamer (bugzilla.gnome.org) bugzilla at gnome.org
Sat Jan 10 07:16:49 PST 2015


https://bugzilla.gnome.org/show_bug.cgi?id=742684
  GStreamer | gst-plugins-bad | git

Sebastian Dröge (slomo) <slomo> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |slomo at coaxion.net

--- Comment #4 from Sebastian Dröge (slomo) <slomo at coaxion.net> 2015-01-10 15:16:46 UTC ---
(In reply to comment #3)
> (In reply to comment #0)
> > g_mutex_lock()
> > g_cond_broadcast();
> > g_mutex_unlock();
> > 
> 
> Broadcasting this way is correct. Are you sure this is the example you wanted
> to show ?

It's probably not correct. When using GCond you always need variables
additional to the GCond to tell the waiter(s) what happened and that something
has happened. And these variables also have to be protected by the same mutex.
Reason for that is that there can also be spurious wakeups without a
signal()/broadcast() and also you usually have multiple conditions to check and
decide on different code paths after waking up.

And g_cond_wait() that is not somehow in a loop like this is suspicious and
probably wrong:

> g_mutex_lock();
> while (!conditions)
>   g_cond_wait();
> g_mutex_unlock()

-- 
Configure bugmail: https://bugzilla.gnome.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the gstreamer-bugs mailing list