Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Draft code
Browse files Browse the repository at this point in the history
Signed-off-by: Zee314159 <[email protected]>
  • Loading branch information
Zee314159 committed Aug 20, 2019
1 parent ef6fe37 commit 9f3e6db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/sota_tools/request_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ RequestPool::RequestPool(const TreehubServer& server, const int max_curl_request
curl_global_init(CURL_GLOBAL_DEFAULT);
multi_ = curl_multi_init();
curl_multi_setopt(multi_, CURLMOPT_PIPELINING, CURLPIPE_HTTP1 | CURLPIPE_MULTIPLEX);

curl = curl_easy_init();
if (curl == nullptr) {
throw std::runtime_error("Could not initialize curl");
}
headers = nullptr;
headers = curl_slist_append(headers, "Content-Type: application/octet-stream");
curlEasySetoptWrapper(curl, CURLOPT_HTTPHEADER, headers);
}

RequestPool::~RequestPool() {
Expand All @@ -26,6 +34,8 @@ RequestPool::~RequestPool() {

curl_multi_cleanup(multi_);
curl_global_cleanup();
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
} catch (std::exception& ex) {
LOG_ERROR << "Exception in RequestPool dtor: " << ex.what();
} catch (...) {
Expand Down
2 changes: 2 additions & 0 deletions src/sota_tools/request_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class RequestPool {
int total_requests_made_{0};
const TreehubServer& server_;
CURLM* multi_;
CURL* curl;
curl_slist* headers;
std::list<OSTreeObject::ptr> query_queue_;
std::list<OSTreeObject::ptr> upload_queue_;
RunMode mode_;
Expand Down

0 comments on commit 9f3e6db

Please sign in to comment.