Commit 8b84e5b3 authored by Max Kellermann's avatar Max Kellermann

input/curl: hold mutex while writing to postponed_error

parent e1d5ddb4
...@@ -63,6 +63,16 @@ AsyncInputStream::Pause() ...@@ -63,6 +63,16 @@ AsyncInputStream::Pause()
paused = true; paused = true;
} }
void
AsyncInputStream::PostponeError(Error &&error)
{
assert(io_thread_inside());
seek_state = SeekState::NONE;
postponed_error = std::move(error);
cond.broadcast();
}
inline void inline void
AsyncInputStream::Resume() AsyncInputStream::Resume()
{ {
......
...@@ -86,6 +86,8 @@ protected: ...@@ -86,6 +86,8 @@ protected:
open = false; open = false;
} }
void PostponeError(Error &&error);
bool IsBufferEmpty() const { bool IsBufferEmpty() const {
return buffer.IsEmpty(); return buffer.IsEmpty();
} }
......
...@@ -777,9 +777,10 @@ CurlInputStream::DoSeek(offset_type new_offset) ...@@ -777,9 +777,10 @@ CurlInputStream::DoSeek(offset_type new_offset)
return; return;
} }
Error error;
if (!InitEasy(postponed_error)) { if (!InitEasy(postponed_error)) {
mutex.lock(); mutex.lock();
SeekDone(); PostponeError(std::move(error));
return; return;
} }
...@@ -790,9 +791,9 @@ CurlInputStream::DoSeek(offset_type new_offset) ...@@ -790,9 +791,9 @@ CurlInputStream::DoSeek(offset_type new_offset)
curl_easy_setopt(easy, CURLOPT_RANGE, range); curl_easy_setopt(easy, CURLOPT_RANGE, range);
} }
if (!input_curl_easy_add_indirect(this, postponed_error)) { if (!input_curl_easy_add_indirect(this, error)) {
mutex.lock(); mutex.lock();
SeekDone(); PostponeError(std::move(error));
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment