From a5c09f4ddb86e140481fd874063f4cfba5b38ea2 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 16 May 2019 22:38:37 +0200 Subject: [PATCH] input/buffering: destruct our input while mutex is unlocked --- src/input/BufferingInputStream.cxx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/input/BufferingInputStream.cxx b/src/input/BufferingInputStream.cxx index 20676ba70..fed4ab0ed 100644 --- a/src/input/BufferingInputStream.cxx +++ b/src/input/BufferingInputStream.cxx @@ -196,7 +196,6 @@ BufferingInputStream::RunThread() noexcept size_t new_offset = FindFirstHole(); if (new_offset == INVALID_OFFSET) { /* the file has been read completely */ - input.reset(); break; } @@ -251,4 +250,14 @@ BufferingInputStream::RunThread() noexcept } else 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(); }