Use a thread queue and pool for asnyc threaded DNS resolves. Add pytest test_21_* for verification. Add `CURLMOPT_RESOLVE_THREADS_MAX` to allow applications to resize the thread pool used. Add `CURLMOPT_QUICK_EXIT` to allow applications to skip thread joins when cleaning up a multi handle. Multi handles in `curl_easy_perform()` inherit this from `CURLOPT_QUICK_EXIT`. Add several debug environment variables for testing. Closes #20936
1.9 KiB
| c | SPDX-License-Identifier | Title | Section | Source | See-also | Protocol | Added-in | |||
|---|---|---|---|---|---|---|---|---|---|---|
| Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. | curl | CURLMOPT_RESOLVE_THREADS_MAX | 3 | libcurl |
|
|
8.20.0 |
NAME
CURLMOPT_RESOLVE_THREADS_MAX - max threads for threaded DNS resolver
SYNOPSIS
#include <curl/curl.h>
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_RESOLVE_THREADS_MAX,
long amount);
DESCRIPTION
Pass a long for the amount. The set number is used as the maximum number of threads to be used for the threaded DNS resolver. It has to be a positive number in the range of 32 bits.
When libcurl is built with a threaded resolver, which is the default on many systems, it uses a thread pool to lookup addresses and other properties of hostnames so other transfers are not blocked by this.
Threads are started on demand to perform the resolving and shut down again after a period of inactivity. When the maximum number of threads is reached, outstanding resolves are held in a queue and served when a thread becomes available.
The default maximum is expected to work fine for many situations. Application may override it using this option for the multi handle.
Changing this value while there are resolves in progress is possible. Increasing the value takes effect right away. Lowering the value does not close down any resolves, but ends threads above the new maximum once the resolving is done.
DEFAULT
%PROTOCOLS%
EXAMPLE
int main(void)
{
CURLM *m = curl_multi_init();
/* never use more than 5 threads for resolving */
curl_multi_setopt(m, CURLMOPT_RESOLVE_THREADS_MAX, 5L);
}
%AVAILABILITY%
RETURN VALUE
curl_multi_setopt(3) returns a CURLMcode indicating success or error.
CURLM_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3).