From 8092e18158e1b334dc6c1bfd7efcb1e96fbe6df6 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 9 Sep 2016 15:41:09 +0200 Subject: [PATCH] input/async: add attribute "postponed_exception" Will replace "postponed_error". --- src/input/AsyncInputStream.cxx | 7 +++++++ src/input/AsyncInputStream.hxx | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/src/input/AsyncInputStream.cxx b/src/input/AsyncInputStream.cxx index 1c2388898..d1445579a 100644 --- a/src/input/AsyncInputStream.cxx +++ b/src/input/AsyncInputStream.cxx @@ -88,6 +88,12 @@ AsyncInputStream::Resume() bool AsyncInputStream::Check(Error &error) { + if (postponed_exception) { + auto e = std::move(postponed_exception); + postponed_exception = std::exception_ptr(); + std::rethrow_exception(e); + } + bool success = !postponed_error.IsDefined(); if (!success) { error = std::move(postponed_error); @@ -181,6 +187,7 @@ bool AsyncInputStream::IsAvailable() { return postponed_error.IsDefined() || + postponed_exception || IsEOF() || !buffer.IsEmpty(); } diff --git a/src/input/AsyncInputStream.hxx b/src/input/AsyncInputStream.hxx index 0d53e3c59..91eb8b3bf 100644 --- a/src/input/AsyncInputStream.hxx +++ b/src/input/AsyncInputStream.hxx @@ -26,6 +26,8 @@ #include "util/CircularBuffer.hxx" #include "util/Error.hxx" +#include + /** * Helper class for moving asynchronous (non-blocking) InputStream * implementations to the I/O thread. Data is being read into a ring @@ -67,6 +69,8 @@ class AsyncInputStream : public InputStream { protected: Error postponed_error; + std::exception_ptr postponed_exception; + public: /** * @param _buffer a buffer allocated with HugeAllocate(); the