From 869d215058df827fc54b1b2805f5c69064083bc1 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 16 May 2019 22:24:25 +0200 Subject: [PATCH] input/buffering: merge "read_error" and "idle" checks in thread --- src/input/BufferingInputStream.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/input/BufferingInputStream.cxx b/src/input/BufferingInputStream.cxx index db332b5fd..9cce7bf5d 100644 --- a/src/input/BufferingInputStream.cxx +++ b/src/input/BufferingInputStream.cxx @@ -146,9 +146,10 @@ BufferingInputStream::RunThread() noexcept seek = false; read_error = {}; client_cond.notify_one(); - } else if (!idle && !read_error && - offset != input->GetOffset() && - !IsAvailable()) { + } else if (read_error || idle) { + /* wait for client to consume the read error */ + wake_cond.wait(lock); + } else if (offset != input->GetOffset() && !IsAvailable()) { /* a past Seek() call was a no-op because data was already available at that position, but now we've reached a new position where @@ -172,8 +173,7 @@ BufferingInputStream::RunThread() noexcept client_cond.notify_one(); OnBufferAvailable(); } - } else if (!idle && !read_error && - input->IsAvailable() && !input->IsEOF()) { + } else if (input->IsAvailable() && !input->IsEOF()) { const auto read_offset = input->GetOffset(); auto w = buffer.Write(read_offset);