Skip to content
Snippets Groups Projects
Commit a059d993 authored by Adrien Béraud's avatar Adrien Béraud Committed by Sébastien Blin
Browse files

manager: increase open files limit if too low

Change-Id: Ic430a8d808ba25f45eec8a92e28aa635e1b69ba9
parent 2f213bb1
No related branches found
No related tags found
No related merge requests found
...@@ -81,6 +81,11 @@ using random_device = dht::crypto::random_device; ...@@ -81,6 +81,11 @@ using random_device = dht::crypto::random_device;
#include "data_transfer.h" #include "data_transfer.h"
#ifndef WIN32
#include <sys/time.h>
#include <sys/resource.h>
#endif
#include <cerrno> #include <cerrno>
#include <ctime> #include <ctime>
#include <cstdlib> #include <cstdlib>
...@@ -670,6 +675,17 @@ Manager::init(const std::string &config_file) ...@@ -670,6 +675,17 @@ Manager::init(const std::string &config_file)
// FIXME: this is no good // FIXME: this is no good
initialized = true; initialized = true;
#ifndef WIN32
// Set the max number of open files.
struct rlimit nofiles;
if (getrlimit(RLIMIT_NOFILE, &nofiles) == 0) {
if (nofiles.rlim_cur < nofiles.rlim_max && nofiles.rlim_cur < 1024u) {
nofiles.rlim_cur = std::min<rlim_t>(nofiles.rlim_max, 8192u);
setrlimit(RLIMIT_NOFILE, &nofiles);
}
}
#endif
#define PJSIP_TRY(ret) do { \ #define PJSIP_TRY(ret) do { \
if (ret != PJ_SUCCESS) \ if (ret != PJ_SUCCESS) \
throw std::runtime_error(#ret " failed"); \ throw std::runtime_error(#ret " failed"); \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment