From: Vladimír Čunát Date: Mon, 16 Apr 2018 13:32:54 +0000 (+0200) Subject: cache TTL limit nitpicks: allow equality, fix docs X-Git-Tag: v2.4.0~47^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d208e7e5b6bce8acded1d173574a19c9da5d3e77;p=thirdparty%2Fknot-resolver.git cache TTL limit nitpicks: allow equality, fix docs I also tried making a clickable define in the docs, like for cache.ns_tout(), but I failed. --- diff --git a/daemon/README.rst b/daemon/README.rst index 975c01c1b..3ec8c8025 100644 --- a/daemon/README.rst +++ b/daemon/README.rst @@ -718,7 +718,10 @@ daemons or manipulated from other processes, making for example synchronised loa .. function:: cache.max_ttl([ttl]) - :param number ttl: maximum cache TTL (default: 6 days) + :param number ttl: maximum cache TTL in seconds (default: 6 days) + + .. KR_CACHE_DEFAULT_TTL_MAX ^^ + :return: current maximum TTL Get or set maximum cache TTL. @@ -738,7 +741,10 @@ daemons or manipulated from other processes, making for example synchronised loa .. function:: cache.min_ttl([ttl]) - :param number ttl: minimum cache TTL (default: 0) + :param number ttl: minimum cache TTL in seconds (default: 5 seconds) + + .. KR_CACHE_DEFAULT_TTL_MIN ^^ + :return: current maximum TTL Get or set minimum cache TTL. Any entry inserted into cache with TTL lower than minimal will be overriden to minimum TTL. Forcing TTL higher than specified violates DNS standards, use with care. diff --git a/daemon/bindings.c b/daemon/bindings.c index bcb9daa21..f3c6e1cb7 100644 --- a/daemon/bindings.c +++ b/daemon/bindings.c @@ -808,7 +808,7 @@ static int cache_max_ttl(lua_State *L) } uint32_t min = cache->ttl_min; int64_t ttl = lua_tonumber(L, 1); - if (ttl < 0 || ttl <= min || ttl > UINT32_MAX) { + if (ttl < 0 || ttl < min || ttl > UINT32_MAX) { format_error(L, "max_ttl must be larger than minimum TTL, and in range <1, " xstr(UINT32_MAX) ">'"); lua_error(L); } @@ -832,7 +832,7 @@ static int cache_min_ttl(lua_State *L) } uint32_t max = cache->ttl_max; int64_t ttl = lua_tonumber(L, 1); - if (ttl < 0 || ttl >= max || ttl > UINT32_MAX) { + if (ttl < 0 || ttl > max || ttl > UINT32_MAX) { format_error(L, "min_ttl must be smaller than maximum TTL, and in range <0, " xstr(UINT32_MAX) ">'"); lua_error(L); }