lib/curl/Init: share a CurlGlobal instance between input and storage

This commit is contained in:
Max Kellermann
2017-08-18 13:13:27 +02:00
parent b2b079a26b
commit b7d0890bc0
5 changed files with 152 additions and 27 deletions

View File

@@ -23,6 +23,7 @@
#include "storage/StorageInterface.hxx"
#include "storage/FileInfo.hxx"
#include "storage/MemoryDirectoryReader.hxx"
#include "lib/curl/Init.hxx"
#include "lib/curl/Global.hxx"
#include "lib/curl/Slist.hxx"
#include "lib/curl/Request.hxx"
@@ -49,16 +50,12 @@
class CurlStorage final : public Storage {
const std::string base;
CurlGlobal *const curl;
CurlInit curl;
public:
CurlStorage(EventLoop &_loop, const char *_base)
:base(_base),
curl(new CurlGlobal(_loop)) {}
~CurlStorage() {
BlockingCall(curl->GetEventLoop(), [this](){ delete curl; });
}
curl(_loop) {}
/* virtual methods from class Storage */
StorageFileInfo GetInfo(const char *uri_utf8, bool follow) override;