Commit a5c09f4d authored by Max Kellermann's avatar Max Kellermann

input/buffering: destruct our input while mutex is unlocked

parent 1acb9bce
...@@ -196,7 +196,6 @@ BufferingInputStream::RunThread() noexcept ...@@ -196,7 +196,6 @@ BufferingInputStream::RunThread() noexcept
size_t new_offset = FindFirstHole(); size_t new_offset = FindFirstHole();
if (new_offset == INVALID_OFFSET) { if (new_offset == INVALID_OFFSET) {
/* the file has been read completely */ /* the file has been read completely */
input.reset();
break; break;
} }
...@@ -251,4 +250,14 @@ BufferingInputStream::RunThread() noexcept ...@@ -251,4 +250,14 @@ BufferingInputStream::RunThread() noexcept
} else } else
wake_cond.wait(lock); wake_cond.wait(lock);
} }
/* clear the "input" attribute while holding the mutex */
auto _input = std::move(input);
/* the mutex must be unlocked while an InputStream can be
destructed */
lock.unlock();
/* and now actually destruct the InputStream */
_input.reset();
} }
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