diff options
author | ILYA Khlopotov <iilyak@apache.org> | 2018-10-15 14:19:41 -0700 |
---|---|---|
committer | ILYA Khlopotov <iilyak@apache.org> | 2018-10-18 11:33:52 -0700 |
commit | 2301cf35b8f08659fcdfcebd260d628b067abefd (patch) | |
tree | d4307fdf0fcbaef48805a5c3ab4dc5579bca7448 | |
parent | 4a76ccbd51786218f8bf20b888bbb23e40a019db (diff) | |
download | couchdb-2301cf35b8f08659fcdfcebd260d628b067abefd.tar.gz |
Fix ets_lru configuration in chttpd application
The code was incorect in a sense that it was using is_integer guard,
while `config:get` cannot return integer.
-rw-r--r-- | src/chttpd/src/chttpd_sup.erl | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/src/chttpd/src/chttpd_sup.erl b/src/chttpd/src/chttpd_sup.erl index fe84b67eb..369248ea6 100644 --- a/src/chttpd/src/chttpd_sup.erl +++ b/src/chttpd/src/chttpd_sup.erl @@ -80,21 +80,18 @@ maybe_replace(Key, Value, Settings) -> end. lru_opts() -> - case config:get("chttpd_auth_cache", "max_objects") of - MxObjs when is_integer(MxObjs), MxObjs > 0 -> - [{max_objects, MxObjs}]; - _ -> - [] - end ++ - case config:get("chttpd_auth_cache", "max_size", "104857600") of - MxSize when is_integer(MxSize), MxSize > 0 -> - [{max_size, MxSize}]; - _ -> - [] - end ++ - case config:get("chttpd_auth_cache", "max_lifetime", "600000") of - MxLT when is_integer(MxLT), MxLT > 0 -> - [{max_lifetime, MxLT}]; - _ -> - [] - end. + lists:foldl(fun append_if_set/2, [], [ + {max_objects, config:get_integer("chttpd_auth_cache", "max_objects", 0)}, + {max_size, config:get_integer("chttpd_auth_cache", "max_size", 104857600)}, + {max_lifetime, config:get_integer("chttpd_auth_cache", "max_lifetime", 600000)} + ]). + +append_if_set({Key, Value}, Opts) when Value > 0 -> + [{Key, Value} | Opts]; +append_if_set({Key, 0}, Opts) -> + Opts; +append_if_set({Key, Value}, Opts) -> + couch_log:error( + "The value for `~s` should be string convertable " + "to integer which is >= 0 (got `~p`)", [Key, Value]), + Opts. |