[Asterisk-code-review] res_http_media_cache: Allow to configure the dns timeout (asterisk[20])
Holger Hans Peter Freyther
asteriskteam at digium.com
Fri Dec 9 01:07:37 CST 2022
Holger Hans Peter Freyther has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/19701 )
Change subject: res_http_media_cache: Allow to configure the dns timeout
......................................................................
res_http_media_cache: Allow to configure the dns timeout
ASTERISK-30340
Change-Id: I6d8af55d670ea342a3faeeb96860f5a9919777b0
---
M res/res_http_media_cache.c
1 file changed, 24 insertions(+), 0 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/01/19701/1
diff --git a/res/res_http_media_cache.c b/res/res_http_media_cache.c
index c8ff0e4..f4e6c06 100644
--- a/res/res_http_media_cache.c
+++ b/res/res_http_media_cache.c
@@ -58,6 +58,9 @@
<configOption name="redir_protocols">
<synopsis>The comma separated list of allowed protocols for redirects. Available with curl 7.85.0 or later. See https://curl.se/libcurl/c/CURLOPT_REDIR_PROTOCOLS_STR.html for details.</synopsis>
</configOption>
+ <configOption name="dns_cache_timeout_seconds">
+ <synopsis>The life-time for DNS cache entries. See https://curl.se/libcurl/c/CURLOPT_DNS_CACHE_TIMEOUT.html for details.</synopsis>
+ </configOption>
</configObject>
</configFile>
</configInfo>
@@ -87,6 +90,7 @@
static char *cache_curl_proxy = NULL;
static char *cache_curl_protocols = NULL;
static char *cache_curl_redir_protocols = NULL;
+static int cache_dns_cache_timeout = 60;
/*! \brief Data passed to cURL callbacks */
@@ -400,6 +404,13 @@
#endif
}
+ CURLcode rc = curl_easy_setopt(curl, CURLOPT_DNS_CACHE_TIMEOUT, cache_dns_cache_timeout);
+ if (rc != CURLE_OK) {
+ ast_log(AST_LOG_ERROR, "Setting dns_cache_timeout to '%d' failed: %d\n", cache_dns_cache_timeout, rc);
+ curl_easy_cleanup(curl);
+ return NULL;
+ }
+
return curl;
}
@@ -652,6 +663,8 @@
ast_free(cache_curl_redir_protocols);
cache_curl_redir_protocols = ast_strdup(var->value);
#endif
+ } else if (strcasecmp(var->name, "dns_cache_timeout_seconds") == 0) {
+ cache_dns_cache_timeout = strtoul(var->value, NULL, 0);
} else {
ast_log(LOG_ERROR, "Unrecognized variable '%s' in category '%s'\n", var->name, cat);
ast_config_destroy(cfg);
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/19701
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 20
Gerrit-Change-Id: I6d8af55d670ea342a3faeeb96860f5a9919777b0
Gerrit-Change-Number: 19701
Gerrit-PatchSet: 1
Gerrit-Owner: Holger Hans Peter Freyther <automatic at freyther.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20221209/b2d9cfcd/attachment.html>
More information about the asterisk-code-review
mailing list