Fix Bug #3463: Force DNS Timeout when forcing a libcurl fresh connection

* Force DNS Timeout when forcing a libcurl fresh connection which will force DNS resolution as stale cache internally in curl is not being released
This commit is contained in:
abraunegg 2025-10-08 06:48:39 +11:00
commit 7575603757

View file

@ -1752,8 +1752,7 @@ class OneDriveApi {
addLogEntry("Internet connectivity to Microsoft OneDrive service has been restored");
}
// unset the fresh connect option as this then creates performance issues if left enabled
if (debugLogging) {addLogEntry("Unsetting libcurl to use a fresh connection as this causes a performance impact if left enabled", ["debug"]);}
curlEngine.http.handle.set(CurlOption.fresh_connect,0);
unsetFreshConnectOption();
}
// On successful processing, break out of the loop
@ -2095,6 +2094,16 @@ class OneDriveApi {
private void setFreshConnectOption() {
if (debugLogging) {addLogEntry("Configuring libcurl to use a fresh connection for re-try", ["debug"]);}
curlEngine.http.handle.set(CurlOption.fresh_connect,1);
//curlEngine.http.handle.set(CurlOption.dns_cache_timeout, 0);
curlEngine.http.dnsTimeout = (dur!"seconds"(0));
}
// Unset the libcurl fresh connection options
private void unsetFreshConnectOption() {
if (debugLogging) {addLogEntry("Unsetting libcurl to use a fresh connection as this causes a performance impact if left enabled", ["debug"]);}
curlEngine.http.handle.set(CurlOption.fresh_connect,0);
//curlEngine.http.handle.set(CurlOption.dns_cache_timeout, 0);
curlEngine.http.dnsTimeout = (dur!"seconds"(appConfig.getValueLong("dns_timeout")));
}
// Generate a HTTP 'reason' based on the HTTP 'code'