From 541468f0cabd5481e1e1574c4b8a990e93eb9ba1 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 28 Jan 2023 07:41:47 +0100 Subject: [PATCH] input/async: check for errors in Seek() Fixes a busy loop in BufferingInputStream::RunThreadLocked() because the method never learns that seeking is ignored, even though the HTTP stream is already broken and can never be read; nobody cared to check for errors. Closes https://github.com/MusicPlayerDaemon/MPD/issues/1727 --- NEWS | 2 ++ src/input/AsyncInputStream.cxx | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index dd8479049..ac1429960 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ ver 0.23.13 (not yet released) +* input + - curl: fix busy loop after connection failed ver 0.23.12 (2023/01/17) * input diff --git a/src/input/AsyncInputStream.cxx b/src/input/AsyncInputStream.cxx index 38ae566ee..4b21f3391 100644 --- a/src/input/AsyncInputStream.cxx +++ b/src/input/AsyncInputStream.cxx @@ -101,9 +101,17 @@ AsyncInputStream::Seek(std::unique_lock &lock, assert(IsReady()); assert(seek_state == SeekState::NONE); - if (new_offset == offset) - /* no-op */ + if (new_offset == offset) { + /* no-op, but if the stream is not open anymore (maybe + because it has failed), nothing can be read, so we + should check for errors here instead of pretending + everything's fine */ + + if (!open) + Check(); + return; + } if (!IsSeekable()) throw std::runtime_error("Not seekable");