mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
Added a deadlock case for the queue
Original commit message from CVS: Added a deadlock case for the queue
This commit is contained in:
parent
4e1993625f
commit
2763642766
1 changed files with 38 additions and 0 deletions
38
docs/random/queue
Normal file
38
docs/random/queue
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
thread 1 thread2
|
||||||
|
|
||||||
|
// the queue is empty
|
||||||
|
while (!queue->level_buffers) {
|
||||||
|
STATUS("queue: %s U released lock\n");
|
||||||
|
GST_UNLOCK (queue);
|
||||||
|
|
||||||
|
// thread1 is scheduled and puts a lot of buffers
|
||||||
|
// in the queue
|
||||||
|
|
||||||
|
// thread1 has put the last buffer on the queue
|
||||||
|
// here. A signal is going to be emited
|
||||||
|
|
||||||
|
tosignal = (queue->level_buffers >= 0);
|
||||||
|
queue->level_buffers++;
|
||||||
|
|
||||||
|
/* we can unlock now */
|
||||||
|
GST_UNLOCK (queue);
|
||||||
|
|
||||||
|
if (tosignal) {
|
||||||
|
g_mutex_lock (queue->emptylock);
|
||||||
|
g_cond_signal (queue->emptycond);
|
||||||
|
g_mutex_unlock (queue->emptylock);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_mutex_lock (queue->emptylock);
|
||||||
|
// wait forever
|
||||||
|
g_cond_wait (queue->emptycond, queue->emptylock);
|
||||||
|
g_mutex_unlock (queue->emptylock);
|
||||||
|
GST_LOCK (queue);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// thread 1 will also wait forever because the
|
||||||
|
// queue is filled....
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue