Is function specified to cURL via CURLOPT_WRITEFUNCTION called from same thread which called curl_easy_perform()?
void read_http()
{
curl_easy_setopt(CURLOPT_WRITEFUNCTION, on_write_data);
curl_easy_perform(hcurl);
}
the callback is like
void on_write_data(buff, ...)
{
copy_to(buff, shared_buff);
}
client code looks like
read_http();
// use shared_buff
question is when read_http() returns has all http data been read? or could it be still in progress?
Yes it is. For all practical purposes libcurl is single-threaded and will never do callbacks from any other thread than the one you call it in.
The only other thread libcurl will ever use (if built that way) is a separate thread for name resolves, but that thread will never do any callbacks or otherwise become visible to the caller or API.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With