# HG changeset patch # User Kim Alvefur # Date 1642529341 -3600 # Node ID c26f515751af7bb85eee9e5927a56e57760d76d0 # Parent adc6241e5d1625f50734577c16eab2715bebfe02 mod_measure_process: Handle unlimited FD limits While unlikely, better type-safe than sorry diff -r adc6241e5d16 -r c26f515751af mod_measure_process/mod_measure_process.lua --- a/mod_measure_process/mod_measure_process.lua Tue Jan 18 18:55:20 2022 +0100 +++ b/mod_measure_process/mod_measure_process.lua Tue Jan 18 19:09:01 2022 +0100 @@ -57,6 +57,13 @@ module:log("warn", "not reporting maximum number of file descriptors because mod_posix is not available") end + local function limit2num(limit) + if limit == "unlimited" then + return math.huge + end + return limit + end + module:hook("stats-update", function () local count = 0 for _ in lfs.dir("/proc/self/fd") do @@ -67,7 +74,7 @@ if has_posix then local ok, soft, hard = posix.getrlimit("NOFILE") if ok then - max_fds:set(soft or hard); + max_fds:set(limit2num(soft or hard)); end end end);