mirror of
https://github.com/hoytech/strfry.git
synced 2025-06-16 16:28:50 +00:00
setRLimits refactor to snarf as many handles available up to asked for
This commit is contained in:
@ -58,9 +58,21 @@ static void setRLimits() {
|
||||
|
||||
if (getrlimit(RLIMIT_NOFILE, &curr)) throw herr("couldn't call getrlimit: ", strerror(errno));
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
LI << "getrlimit NOFILES limit current " << curr.rlim_cur << " with max of " << curr.rlim_max;
|
||||
if (cfg().relay__nofiles > curr.rlim_max) {
|
||||
LI << "Unable to set NOFILES limit to " << cfg().relay__nofiles << ", exceeds max of " << curr.rlim_max;
|
||||
if (curr.rlim_cur < curr.rlim_max) {
|
||||
LI << "Setting NOFILES limit to max of " << curr.rlim_max;
|
||||
curr.rlim_cur = curr.rlim_max;
|
||||
}
|
||||
}
|
||||
else curr.rlim_cur = cfg().relay__nofiles;
|
||||
LI << "setrlimit NOFILES limit to " << curr.rlim_cur;
|
||||
#else
|
||||
if (cfg().relay__nofiles > curr.rlim_max) throw herr("Unable to set NOFILES limit to ", cfg().relay__nofiles, ", exceeds max of ", curr.rlim_max);
|
||||
|
||||
curr.rlim_cur = cfg().relay__nofiles;
|
||||
#endif
|
||||
|
||||
if (setrlimit(RLIMIT_NOFILE, &curr)) throw herr("Failed setting NOFILES limit to ", cfg().relay__nofiles, ": ", strerror(errno));
|
||||
}
|
||||
@ -69,10 +81,5 @@ static void setRLimits() {
|
||||
void onAppStartup(lmdb::txn &txn, const std::string &cmd) {
|
||||
dbCheck(txn, cmd);
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
// XXX - strfry error: Unable to set NOFILES limit to 1000000, exceeds max of 116991
|
||||
// XXX - warning: comparison of integer expressions of different signedness:
|
||||
// XXX 'const uint64_t' {aka 'const long unsigned int'} and 'rlim_t' {aka 'long int'} [-Wsign-compare]
|
||||
setRLimits();
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user