queue2: fix possible data corruption in ring buffer mode when seeking
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Thu, 24 May 2012 12:08:16 +0000 (13:08 +0100)
committerTim-Philipp Müller <tim@centricular.net>
Wed, 12 Sep 2012 11:59:50 +0000 (12:59 +0100)
commit2fe8ebaae63c9db43c9eee7b47678a3da31cf046
tree08f606bb5a217067d653f56ab5b11f541679163e
parent232fd2953eb00f694b667e7796704f5974cea452
queue2: fix possible data corruption in ring buffer mode when seeking

Fix race that could cause data corruption when seeking in ring buffer
mode.

In perform_seek_to_offset(), called from the demuxer's pull_range
request, we drop the lock, tell upstream (usually a http source)
to seek to a different offset, then re-acquire the lock before we
do things to the ranges. However, between us sending the seek event
and re-acquiring the lock, the source thread might already have pushed
some data and moved along the range's writing_pos beyond the seek
offset. In that case we don't want to set the writing position back
to the requested seek position, as it would cause data to be written
to the wrong offset in the file or ring buffer.

Reproducible doing seek-emulated fast-forward/backward on 006653.

Conflicts:
plugins/elements/gstqueue2.c
plugins/elements/gstqueue2.c