]> git.ipfire.org Git - thirdparty/curl.git/commit
multi: fix curl_multi_waitfds reporting of fd_count 15155/head
authorChristopher Dannemiller <cdannemiller@nvidia.com>
Fri, 4 Oct 2024 16:31:59 +0000 (09:31 -0700)
committerJay Satiro <raysatiro@yahoo.com>
Sun, 29 Dec 2024 06:05:09 +0000 (01:05 -0500)
commitc78044c07e97cb720049579f4fe3cab33a7ea8d3
treec609f7e1279a34cc28736dc7460e9daf39b16def
parent7d6edf1d8d98b182663eab11779ae2e73d754a7e
multi: fix curl_multi_waitfds reporting of fd_count

- Make curl_multi_waitfds consistent with the documentation.

Issue Addressed:

 - The documentation of curl_multi_waitfds indicates that users should
   be able to call curl_multi_waitfds with a NULL ufds. However, before
   this change, the function would return CURLM_BAD_FUNCTION_ARGUMENT.
 - Additionally, the documentation suggests that users can use this
   function to determine the number of file descriptors (fds) needed.
   However, the function would stop counting fds if the supplied fds
   were exhausted.

Changes Made:

 - NULL ufds Handling: curl_multi_waitfds can now accept a NULL ufds if
   size is also zero.
 - Counting File Descriptors: If curl_multi_waitfds is passed a NULL
   ufds, or the size of ufds is insufficient, the output parameter
   fd_count will return the number of fds needed. This value may be
   higher than actually needed but never lower.

Testing:

 - Test 2405 has been updated to cover the usage scenarios described
   above.

Fixes https://github.com/curl/curl/issues/15146
Closes https://github.com/curl/curl/pull/15155
docs/libcurl/curl_multi_waitfds.md
lib/conncache.c
lib/conncache.h
lib/multi.c
lib/select.c
lib/select.h
tests/libtest/lib2405.c