curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: Multithreading with libcurl

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 15 Dec 2016 09:12:50 +0100 (CET)

On Thu, 15 Dec 2016, Milo Ljumovi wrote:

> It works fine, although I am keep getting output like "forcibly told to
> drain data" when using curl_multi_info_read.

I'm sorry but I don't understand what this means.

The "forcibly told to drain data" is not really "output you get", it is a
debug info string that is there for debug builds only and only serves as a
hint for us to understand the code flow in some specific cases (and should
probably be removed). It is not related to curl_multi_info_read() at all!

> If that's fine, good - but I suspect that, something might be wrong and at
> some point app will crash.

I suggest you focus on how to reproduce that crash.

> Recently I had to introduce reading the http response using write_callback
> which complicates my application even further

I don't see how that can complicate any download much and it surprises me that
you even had something going _without_ using the write callback in the first
place.

> cause entire logic with multi interface is asynchronous and after I added
> the write_callback it required me introducing more structures and more
> synchronization mechanisms (to properly determine for which of concurrent
> requests write_callback was invoked).

Surely you want to make sure that downloaded data chunks end up in the correct
destination? How is that the write callback's fault?

> I wanted to re-code it properly, if possible using the easy interface cause I
> assume that unlike when using multi interface, write_callback will be invoked
> (if http response exists)

The write callback is the only way libcurl delivers data to your application.
Well, unless you use the built-in "callback" which can save directly to a FILE
*, but that's usually too restrictive for most applications.

So the callback is called the same way whichever libcurl API you use.

> What I do not understand is why openssl requires more than one mutex?

I think you need to ask the OpenSSL team that question.

-- 
  / daniel.haxx.se

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-12-15