mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-01 06:45:35 +00:00
sfd: Lift up own fd limit on bootup
This minimize chances to hit problem where files used for page transfer are trying to use same number reserved for service fd. Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
This commit is contained in:
committed by
Andrei Vagin
parent
b55eb53c1e
commit
d0ffc478ea
@@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
|
||||||
#include "int.h"
|
#include "int.h"
|
||||||
#include "page.h"
|
#include "page.h"
|
||||||
#include "common/compiler.h"
|
#include "common/compiler.h"
|
||||||
@@ -231,6 +234,20 @@ static void soccr_print_on_level(unsigned int loglevel, const char *format, ...)
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void rlimit_unlimit_nofile_self(void)
|
||||||
|
{
|
||||||
|
struct rlimit new;
|
||||||
|
|
||||||
|
new.rlim_cur = kdat.sysctl_nr_open;
|
||||||
|
new.rlim_max = kdat.sysctl_nr_open;
|
||||||
|
|
||||||
|
if (prlimit(getpid(), RLIMIT_NOFILE, &new, NULL)) {
|
||||||
|
pr_perror("rlimir: Can't setup RLIMIT_NOFILE for self");
|
||||||
|
return;
|
||||||
|
} else
|
||||||
|
pr_debug("rlimit: RLIMIT_NOFILE unlimited for self\n");
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[], char *envp[])
|
int main(int argc, char *argv[], char *envp[])
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -339,6 +356,24 @@ int main(int argc, char *argv[], char *envp[])
|
|||||||
|
|
||||||
init_opts();
|
init_opts();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Service fd engine implies that file descritprs
|
||||||
|
* used won't be borrowed by the rest of the code
|
||||||
|
* and default 1024 limit is not enough for high
|
||||||
|
* loaded test/containers. Thus use kdat engine
|
||||||
|
* to fetch current system level limit for numbers
|
||||||
|
* of files allowed to open up and lift up own
|
||||||
|
* limits.
|
||||||
|
*
|
||||||
|
* Note we have to do it before the service fd
|
||||||
|
* get inited and we dont exit with errors here
|
||||||
|
* because in worst scenario where clash of fd
|
||||||
|
* happen we simply exit with explicit error
|
||||||
|
* during real action stage.
|
||||||
|
*/
|
||||||
|
if (!kerndat_files_stat(true))
|
||||||
|
rlimit_unlimit_nofile_self();
|
||||||
|
|
||||||
if (init_service_fd())
|
if (init_service_fd())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user