curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

RE: Question/proposal about function returning pollfds from multi handle

From: Daniel Stenberg via curl-library <>
Date: Mon, 18 Dec 2023 16:40:02 +0100 (CET)

On Thu, 14 Dec 2023, Dmitry Karpov via curl-library wrote:

> Probably, it would make sense to also return the count of descriptors, like:
> CURLMcode curl_multi_pollfds(struct curl_waitfd *ufds, unsigned int size,
> unsigned int* fd_count);
> The fd_count will tell the client code how many descriptors the multi-handle actually has.

How about this tweak:

  curl_multi_pollfds(struct Curl_multi *multi,
                     struct curl_waitfd **ufds,
                     unsigned int *fd_count);

It returns a pointer to an array of descriptors and fd_count is the number of
entries in that array. The array is allocated by libcurl and is stored
associated with the multi handle so it is freed with the handle. Calling this
function several times will then just overwrite the same array so it does not
have to get reallocated, unless it needs to grow, during a program's lifetime.

It seems less complicated than having the caller pass in an array of a size it
can't know how big it needs to be. The downside is of course that the data in
the array will not survive calling the function again.

  | Commercial curl support up to 24x7 is available!
  | Private help, bug fixes, support, ports, new features
Received on 2023-12-18