8 #include <sys/resource.h> 10 #include <boost/iterator/counting_iterator.hpp> 21 if (getrlimit(RLIMIT_NOFILE, &r) != 0) {
23 "Error: getrlimit(RLIMIT_NOFILE) errno={} {}",
32 return setrlimit(RLIMIT_NOFILE, &r) == 0;
49 if (r.rlim_max == RLIM_INFINITY) {
50 SL_VERBOSE(log(),
"current={} max=unlimited", r.rlim_cur);
52 SL_VERBOSE(log(),
"current={} max={}", r.rlim_cur, r.rlim_max);
54 const rlim_t current = r.rlim_cur;
55 if (limit == current) {
59 if (limit < current) {
60 SL_WARN(log(),
"requested limit is lower than system allowed limit");
63 std::upper_bound(boost::counting_iterator{current},
64 boost::counting_iterator{rlim_t{limit}},
66 [&](std::nullptr_t, rlim_t current) {
74 if (r.rlim_cur != current) {
75 SL_VERBOSE(log(),
"changed current={}", r.rlim_cur);
void setFdLimit(size_t limit)
static const std::string defaultGroupName("kagome")
Logger createLogger(const std::string &tag)
std::optional< size_t > getFdLimit()