summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-12-23 13:37:58 +0100
committerMax Kellermann <max@musicpd.org>2019-12-23 13:37:58 +0100
commitd01fb6730a7ac889f104490022c9dbb581e45db2 (patch)
treed077ae1ebd5c7c9127a07256299a422a110fa64c /src
parent7bfe6a33043fee920703a06ff0b38d049b4b4647 (diff)
storage/curl: move start call out of the constructor
This can cause request completion in the I/O thread before this constructor returns, leaving the object in an abstract state, causing a crash due to pure virtual method call. We should not start the request until this object is fully constructed. Closes https://github.com/MusicPlayerDaemon/MPD/issues/665
Diffstat (limited to 'src')
-rw-r--r--src/storage/plugins/CurlStorage.cxx5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/storage/plugins/CurlStorage.cxx b/src/storage/plugins/CurlStorage.cxx
index b4e73ba0a..5417dae29 100644
--- a/src/storage/plugins/CurlStorage.cxx
+++ b/src/storage/plugins/CurlStorage.cxx
@@ -109,7 +109,9 @@ public:
BIND_THIS_METHOD(OnDeferredStart)),
request(curl, uri, *this) {
// TODO: use CurlInputStream's configuration
+ }
+ void DeferStart() noexcept {
/* start the transfer inside the IOThread */
defer_start.Schedule();
}
@@ -283,6 +285,7 @@ public:
}
using BlockingHttpRequest::GetEasy;
+ using BlockingHttpRequest::DeferStart;
using BlockingHttpRequest::Wait;
protected:
@@ -430,6 +433,7 @@ public:
}
const StorageFileInfo &Perform() {
+ DeferStart();
Wait();
return info;
}
@@ -481,6 +485,7 @@ public:
base_path(UriPathOrSlash(uri)) {}
std::unique_ptr<StorageDirectoryReader> Perform() {
+ DeferStart();
Wait();
return ToReader();
}