multi: add CURLMOPT_NETWORK_CHANGED to signal network changed

New multi option CURLMOPT_NETWORK_CHANGED with a long bitmask value:

- CURLM_NWCOPT_CLEAR_CONNS: do not reuse existing connections, close all
  idle connections.

- CURLM_NWCOPT_CLEAR_DNS: clear the multi's DNS cache.

All other bits reserved for future extensions.

Fixes #17225
Reported-by: ウさん
Closes #17613
This commit is contained in:
Stefan Eissing 2025-06-13 12:38:44 +02:00 committed by Daniel Stenberg
parent 7b8594176d
commit 55c045c863
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
19 changed files with 354 additions and 4 deletions

View file

@ -3235,6 +3235,16 @@ CURLMcode curl_multi_setopt(CURLM *m,
multi->max_concurrent_streams = (unsigned int)streams;
}
break;
case CURLMOPT_NETWORK_CHANGED: {
long val = va_arg(param, long);
if(val & CURLM_NWCOPT_CLEAR_DNS) {
Curl_dnscache_clear(multi->admin);
}
if(val & CURLM_NWCOPT_CLEAR_CONNS) {
Curl_cpool_nw_changed(multi->admin);
}
break;
}
default:
res = CURLM_UNKNOWN_OPTION;
break;