MFC r199804:

Avoid sshd, crond, inetd and syslogd to be killed in an high-pressure
swapping environment.

Sponsored by:	Sandvine Incorporated
This commit is contained in:
attilio 2009-12-19 19:35:53 +00:00
parent d98cd8f494
commit 11e4f3cd81
4 changed files with 17 additions and 0 deletions

View File

@ -47,6 +47,7 @@ __RCSID("$FreeBSD$");
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/socket.h>
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
@ -1292,6 +1293,10 @@ main(int ac, char **av)
/* Initialize configuration options to their default values. */
initialize_server_options(&options);
/* Avoid killing the process in high-pressure swapping environments. */
if (madvise(NULL, 0, MADV_PROTECT) != 0)
debug("madvise(): %.200s", strerror(errno));
/* Parse command-line arguments. */
while ((opt = getopt(ac, av, "f:p:b:k:h:g:u:o:C:dDeiqrtQRT46")) != -1) {
switch (opt) {

View File

@ -24,6 +24,7 @@ static const char rcsid[] =
#include "cron.h"
#include <sys/mman.h>
#include <sys/signal.h>
#if SYS_TIME_H
# include <sys/time.h>
@ -134,6 +135,9 @@ main(argc, argv)
}
}
if (madvise(NULL, 0, MADV_PROTECT) != 0)
log_it("CRON", getpid(), "WARNING", "madvise() failed");
pidfile_write(pfh);
database.head = NULL;
database.tail = NULL;

View File

@ -110,6 +110,7 @@ __FBSDID("$FreeBSD$");
*/
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/resource.h>
@ -497,6 +498,9 @@ main(int argc, char **argv)
}
}
if (madvise(NULL, 0, MADV_PROTECT) != 0)
syslog(LOG_WARNING, "madvise() failed: %s", strerror(errno));
for (i = 0; i < PERIPSIZE; ++i)
LIST_INIT(&proctable[i]);

View File

@ -77,6 +77,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/socket.h>
@ -352,6 +353,9 @@ main(int argc, char *argv[])
pid_t ppid = 1, spid;
socklen_t len;
if (madvise(NULL, 0, MADV_PROTECT) != 0)
dprintf("madvise() failed: %s\n", strerror(errno));
bindhostname = NULL;
while ((ch = getopt(argc, argv, "468Aa:b:cCdf:kl:m:nop:P:sS:Tuv"))
!= -1)