threadshare: Don't drain the queue when trying to push pending items

Otherwise we'll have to collect all failed items and push them back.
Instead pop items one by one, and if one fails just push that single
item back to the front.

The previous code would've lost all items after the first one that
failed
This commit is contained in:
Sebastian Dröge 2018-05-17 11:57:50 +03:00
parent 51aa06d013
commit 7ac9534322
2 changed files with 6 additions and 8 deletions

View file

@ -449,15 +449,14 @@ impl ProxySink {
{
if let &Some(ref queue) = queue {
let mut failed_item = None;
for item in items.drain(..) {
while let Some(item) = items.pop_front() {
if let Err(item) = queue.push(item) {
failed_item = Some(item);
break;
}
}
if let Some(item) = failed_item {
items.push_front(item);
if let Some(failed_item) = failed_item {
items.push_front(failed_item);
*task = Some(task::current());
gst_log!(
sink.cat,

View file

@ -344,15 +344,14 @@ impl Queue {
let res = if let Some((ref mut task, _, ref mut items)) = *pending_queue
{
let mut failed_item = None;
for item in items.drain(..) {
while let Some(item) = items.pop_front() {
if let Err(item) = dq.as_ref().unwrap().push(item) {
failed_item = Some(item);
break;
}
}
if let Some(item) = failed_item {
items.push_front(item);
if let Some(failed_item) = failed_item {
items.push_front(failed_item);
*task = Some(task::current());
gst_log!(
queue.cat,