Skip to content

Add asynchronous downloader that reuses connections to CCDB - #9992

Closed
TrifleMichael wants to merge 1 commit into
AliceO2Group:devfrom
TrifleMichael:AsynchronousDownloadsSquashed
Closed

Add asynchronous downloader that reuses connections to CCDB#9992
TrifleMichael wants to merge 1 commit into
AliceO2Group:devfrom
TrifleMichael:AsynchronousDownloadsSquashed

Conversation

@TrifleMichael

Copy link
Copy Markdown
Contributor

This change adds a downloader capable of parallel and asynchronous curl calls, with the ability to make callback functions after a request is finished.

A lot of the code is base on an example from the curl manual which combines libuv with libcurl (https://curl.se/libcurl/c/multi-uv.html)

The main differences between the example and this code are:

  • a mechanism that closes sockets after a set period of time,
  • the loop runs a parallel thread to the rest of the program.

In case of any questions or remarks please contact me at trzebuniak@student.agh.edu.pl

@costing

costing commented Nov 23, 2022

Copy link
Copy Markdown
Collaborator

@ktf bumping this thread not to loose track of it

@costing costing reopened this Nov 23, 2022
@github-actions github-actions Bot closed this Nov 29, 2022
@costing

costing commented Nov 29, 2022

Copy link
Copy Markdown
Collaborator

@ktf , did you have a chance at checking out the updated pr ?

@costing costing reopened this Nov 29, 2022
Comment thread CCDB/src/CcdbApi.cxx

void CcdbApi::curlInit()
{
std::cout << "Creating downloader\n";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No cout.

Comment thread CCDB/src/CcdbApi.cxx
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curlSetSSLOptions(curl);
res = curl_easy_perform(curl);
std::cout << "mUrl " << mUrl.data() << "\n";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the LOG macro


size_t writeToString(void *contents, size_t size, size_t nmemb, std::string *dst)
{
char *conts = (char *)contents;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if using an std::string for the payload is a good idea.

@ktf

ktf commented Dec 5, 2022

Copy link
Copy Markdown
Member

Sorry for taking so long to have a look at this. Apart from fixing the clang-format and dropping the various cout, I think the main issue is that you are using a std::string for the payload. Why is that? Could you move to a preallocated buffer with the correct size?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants