curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: Libcurl handles and file descriptors and select

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 12 Oct 2017 14:54:11 +0200 (CEST)

On Thu, 12 Oct 2017, surya chandrika via curl-library wrote:

> -> When is the file descriptors actually associated with a handle.

I'm not sure that's good question. Each handle may have one or more file
descriptors associated with it at any time during its life time. You're better
off not trying to second guess when and when not. It depends entirely on the
state of the transfer(s) that the handle is involved with.

> -> Is there any limitation in the number of handles that can be created by a
> process.

There is no limit enforced by libcurl itself, no, but there are typically
steill some limits that are in place: the maximum number of simultanously open
file descriptors in your process for example. By default on most unix like
systems, that number is 1024 (and I believe even less on Windows). Also, going
beyond 1024 might give you problems if you want to use select() and aren't
careful.

But if you intend to use a large number of parallel transfers, you really
should not use select() anyway in the first place.

> 3. multiple threads which in turn will call curl_multi_perform and post to
> remote host.

Just make sure each libcurl-using thread is completely independent or uses
mutexes to ensure that each handle is only ever used by one process at a time:
https://curl.haxx.se/libcurl/c/threadsafe.html

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2017-10-12