input: wake callers on errors and EOF - #2576
Conversation
| CommitWriteBuffer(nbytes); | ||
| } | ||
| catch (...) { | ||
| const std::lock_guard protect{mutex}; |
There was a problem hiding this comment.
This change is correct, but hiding it inside this unrelated commit is not. This should be a separate commit with a commit message explaining the fix.
| const SongLoader &loader, | ||
| const char *uri, | ||
| SongEnumerator &e) noexcept | ||
| SongEnumerator &e) |
There was a problem hiding this comment.
Huh? Unrelated undocumented change?
| unsigned start_index, | ||
| unsigned end_index, | ||
| bool detail) noexcept | ||
| bool detail) |
There was a problem hiding this comment.
Huh? Unrelated undocumented change?
| unsigned start_index, | ||
| unsigned end_index, | ||
| SongFilter *filter) noexcept | ||
| SongFilter *filter) |
There was a problem hiding this comment.
Huh? Unrelated undocumented change?
SongEnumerator::NextSong() can throw while reading a remote playlist. The provider helpers are called by functions that already propagate errors, but their noexcept specifiers turn these failures into std::terminate. Remove noexcept so the command handler can report the I/O error.
DispatchSockets() writes postponed_exception from its catch handler without holding the input stream mutex. A synchronous reader can access the same state after it is notified. Acquire the mutex before storing the exception and notifying readers.
AsyncInputStream::Read() waits on caller_cond, but several asynchronous EOF and error paths only notify the InputStream handler. Since bd78307, the synchronous caller is not the installed handler and can remain blocked forever. Wrap InvokeOnAvailable() so every availability notification also wakes caller_cond.
92e72d1 to
6785a54
Compare
|
Split these changes into separate documented commits. The |
|
Much better, thanks. |
AsyncInputStream::Read()waits oncaller_cond, but EOF and error callbacks in asynchronous input implementations only calledInvokeOnAvailable(). Afterbd7830794, that no longer wakes synchronous readers. Commands that enumerate a truncated remote playlist can therefore leave MPD's main thread blocked indefinitely.Make
AsyncInputStreamnotifycaller_condwhenever it invokes the availability handler, covering all asynchronous implementations. Removenoexceptfrom the playlist enumeration helpers so I/O errors reach the command handler instead of terminating MPD after the reader is woken.