Commit d01fb673 authored by Max Kellermann's avatar Max Kellermann

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
parent 7bfe6a33
ver 0.21.18 (not yet released) ver 0.21.18 (not yet released)
* output * output
- alsa: fix hang bug with ALSA "null" outputs - alsa: fix hang bug with ALSA "null" outputs
* storage
- curl: fix crash bug
* reduce unnecessary CPU wakeups * reduce unnecessary CPU wakeups
ver 0.21.17 (2019/12/16) ver 0.21.17 (2019/12/16)
......
...@@ -109,7 +109,9 @@ public: ...@@ -109,7 +109,9 @@ public:
BIND_THIS_METHOD(OnDeferredStart)), BIND_THIS_METHOD(OnDeferredStart)),
request(curl, uri, *this) { request(curl, uri, *this) {
// TODO: use CurlInputStream's configuration // TODO: use CurlInputStream's configuration
}
void DeferStart() noexcept {
/* start the transfer inside the IOThread */ /* start the transfer inside the IOThread */
defer_start.Schedule(); defer_start.Schedule();
} }
...@@ -283,6 +285,7 @@ public: ...@@ -283,6 +285,7 @@ public:
} }
using BlockingHttpRequest::GetEasy; using BlockingHttpRequest::GetEasy;
using BlockingHttpRequest::DeferStart;
using BlockingHttpRequest::Wait; using BlockingHttpRequest::Wait;
protected: protected:
...@@ -430,6 +433,7 @@ public: ...@@ -430,6 +433,7 @@ public:
} }
const StorageFileInfo &Perform() { const StorageFileInfo &Perform() {
DeferStart();
Wait(); Wait();
return info; return info;
} }
...@@ -481,6 +485,7 @@ public: ...@@ -481,6 +485,7 @@ public:
base_path(UriPathOrSlash(uri)) {} base_path(UriPathOrSlash(uri)) {}
std::unique_ptr<StorageDirectoryReader> Perform() { std::unique_ptr<StorageDirectoryReader> Perform() {
DeferStart();
Wait(); Wait();
return ToReader(); return ToReader();
} }
......
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