mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-13 20:58:20 +00:00
base-linux: boost max open fds to the hard rlimit
This patch increases the default limit of the maximum number of open file descriptors to the hard limit of the system. This is needed for complex scenarios, which require more FDs than the default of 1024 at core. Related to issue #3581 Fixes #3721
This commit is contained in:
committed by
Christian Helmuth
parent
22d71d5a8b
commit
7bf47b1982
@ -19,6 +19,7 @@
|
||||
|
||||
#define size_t __SIZE_TYPE__ /* see comment in 'linux_syscalls.h' */
|
||||
#include <sys/stat.h>
|
||||
#include <sys/resource.h>
|
||||
#include <fcntl.h>
|
||||
#undef size_t
|
||||
|
||||
@ -72,6 +73,7 @@ inline int lx_stat(const char *path, struct stat64 *buf)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************
|
||||
** Functions used by core's io port session support code **
|
||||
***********************************************************/
|
||||
@ -180,6 +182,27 @@ inline void lx_disable_aslr()
|
||||
}
|
||||
|
||||
|
||||
/***********************************
|
||||
** Resource-limit initialization **
|
||||
***********************************/
|
||||
|
||||
inline void lx_boost_rlimit()
|
||||
{
|
||||
rlimit rlimit { };
|
||||
|
||||
if (int const res = lx_syscall(SYS_getrlimit, RLIMIT_NOFILE, &rlimit)) {
|
||||
Genode::warning("unable to obtain RLIMIT_NOFILE (", res, "), keeping limit unchanged");
|
||||
return;
|
||||
}
|
||||
|
||||
/* increase soft limit to hard limit */
|
||||
rlimit.rlim_cur = rlimit.rlim_max;
|
||||
|
||||
if (int const res = lx_syscall(SYS_setrlimit, RLIMIT_NOFILE, &rlimit))
|
||||
Genode::warning("unable to boost RLIMIT_NOFILE (", res, "), keeping limit unchanged");
|
||||
}
|
||||
|
||||
|
||||
/********************************************
|
||||
** Communication over Unix-domain sockets **
|
||||
********************************************/
|
||||
|
@ -94,6 +94,9 @@ Platform::Platform()
|
||||
/* make 'mmap' behave deterministically */
|
||||
lx_disable_aslr();
|
||||
|
||||
/* increase maximum number of open file descriptors to the hard limit */
|
||||
lx_boost_rlimit();
|
||||
|
||||
/* catch control-c */
|
||||
lx_sigaction(LX_SIGINT, sigint_handler, false);
|
||||
|
||||
|
Reference in New Issue
Block a user