Prevent swapping by locking procress's virtual address space into RAM

This commit is contained in:
Arnaud ANDRE 2016-01-22 21:20:51 +01:00
parent 9f3e6f8659
commit 96a61cbac3
1 changed files with 6 additions and 0 deletions

View File

@ -24,6 +24,7 @@
#include <unistd.h>
#include <signal.h>
#include <sys/file.h>
#include <sys/mman.h>
#include "uvrrpd.h"
#include "vrrp.h"
@ -125,6 +126,9 @@ int main(int argc, char *argv[])
/* pidfile */
pidfile(vrrp.vrid);
/* lock procress's virtual address space into RAM */
mlockall(MCL_CURRENT | MCL_FUTURE);
/* process */
set_bit(KEEP_GOING, &reg);
while (test_bit(KEEP_GOING, &reg) && !vrrp_process(&vrrp, &vnet));
@ -148,6 +152,8 @@ int main(int argc, char *argv[])
ctrlfile_unlink();
free(pidfile_name);
munlockall();
return EXIT_SUCCESS;
}