diff options
author | Thorvald Natvig <slicer@users.sourceforge.net> | 2010-01-16 02:56:20 +0300 |
---|---|---|
committer | Thorvald Natvig <slicer@users.sourceforge.net> | 2010-01-16 02:56:20 +0300 |
commit | 814752a8075e436efac55905ba2698b7fe81af98 (patch) | |
tree | 62ba031e5ad8352c9547e57b7aa2bb2efdbdaceb /src | |
parent | 3a50ef51978d2b1abdb54a8d1b7eba1169a543ae (diff) |
Request CAP_SYS_RESOURCE and dynamically increase nofile on demand
Diffstat (limited to 'src')
-rw-r--r-- | src/murmur/Meta.cpp | 16 | ||||
-rw-r--r-- | src/murmur/UnixMurmur.cpp | 2 |
2 files changed, 13 insertions, 5 deletions
diff --git a/src/murmur/Meta.cpp b/src/murmur/Meta.cpp index 2cfe114d0..11b38bab8 100644 --- a/src/murmur/Meta.cpp +++ b/src/murmur/Meta.cpp @@ -461,10 +461,18 @@ bool Meta::boot(int srvnum) { struct rlimit r; if (getrlimit(RLIMIT_NOFILE, &r) == 0) { - if (r.rlim_cur < r.rlim_max) { - r.rlim_cur = r.rlim_max; - setrlimit(RLIMIT_NOFILE, &r); - getrlimit(RLIMIT_NOFILE, &r); + if (r.rlim_cur < sockets) { + r.rlim_cur = sockets; + if (r.rlim_max < sockets) + r.rlim_max = sockets; + if (setrlimit(RLIMIT_NOFILE, &r) != 0) { + getrlimit(RLIMIT_NOFILE, &r); + if (r.rlim_cur < r.rlim_max) { + r.rlim_cur = r.rlim_max; + setrlimit(RLIMIT_NOFILE, &r); + getrlimit(RLIMIT_NOFILE, &r); + } + } } if (r.rlim_cur < sockets) qCritical("Current booted servers require minimum %d file descriptors when all slots are full, but only %d file descriptors are allowed for this process. Your server will crash and burn; read the FAQ for details.", sockets, r.rlim_cur); diff --git a/src/murmur/UnixMurmur.cpp b/src/murmur/UnixMurmur.cpp index 22f8e2be8..eeeb67c0c 100644 --- a/src/murmur/UnixMurmur.cpp +++ b/src/murmur/UnixMurmur.cpp @@ -273,7 +273,7 @@ void UnixMurmur::initialcap() { void UnixMurmur::finalcap() { #ifdef Q_OS_LINUX - cap_value_t caps[] = {CAP_NET_ADMIN}; + cap_value_t caps[] = {CAP_NET_ADMIN, CAP_SYS_RESOURCE}; struct rlimit r; if (! bRoot) |