queue2: flush differently, avoiding deadlocks

Don't flush the file by closing and opening it but instead use g_freopen. This
avoids a deadlock in shutdown because we emit the temp-location property change
with the wrong lock held.
This commit is contained in:
Wim Taymans 2009-07-10 21:01:39 +01:00 committed by Sebastian Dröge
parent affe0aef6f
commit 49c01cce93

View file

@ -1088,12 +1088,25 @@ gst_queue_close_temp_location_file (GstQueue * queue)
queue->temp_file = NULL;
}
static void
gst_queue_flush_temp_file (GstQueue * queue)
{
if (queue->temp_file == NULL)
return;
GST_DEBUG_OBJECT (queue, "flushing temp file");
queue->temp_file = g_freopen (queue->temp_location, "wb+", queue->temp_file);
queue->writing_pos = 0;
queue->reading_pos = 0;
}
static void
gst_queue_locked_flush (GstQueue * queue)
{
if (QUEUE_IS_USING_TEMP_FILE (queue)) {
gst_queue_close_temp_location_file (queue);
gst_queue_open_temp_location_file (queue);
gst_queue_flush_temp_file (queue);
} else {
while (!g_queue_is_empty (queue->queue)) {
GstMiniObject *data = g_queue_pop_head (queue->queue);