From owner-svn-src-stable-8@FreeBSD.ORG Sat Dec 19 19:35:53 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 869C0106568F; Sat, 19 Dec 2009 19:35:53 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 73AE58FC19; Sat, 19 Dec 2009 19:35:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nBJJZr0x041929; Sat, 19 Dec 2009 19:35:53 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nBJJZr2H041924; Sat, 19 Dec 2009 19:35:53 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <200912191935.nBJJZr2H041924@svn.freebsd.org> From: Attilio Rao Date: Sat, 19 Dec 2009 19:35:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r200738 - in stable/8: crypto/openssh usr.sbin/cron/cron usr.sbin/inetd usr.sbin/syslogd X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Dec 2009 19:35:53 -0000 Author: attilio Date: Sat Dec 19 19:35:53 2009 New Revision: 200738 URL: http://svn.freebsd.org/changeset/base/200738 Log: MFC r199804: Avoid sshd, crond, inetd and syslogd to be killed in an high-pressure swapping environment. Sponsored by: Sandvine Incorporated Modified: stable/8/crypto/openssh/sshd.c stable/8/usr.sbin/cron/cron/cron.c stable/8/usr.sbin/inetd/inetd.c stable/8/usr.sbin/syslogd/syslogd.c Directory Properties: stable/8/crypto/openssh/ (props changed) stable/8/usr.sbin/cron/ (props changed) stable/8/usr.sbin/inetd/ (props changed) stable/8/usr.sbin/syslogd/ (props changed) Modified: stable/8/crypto/openssh/sshd.c ============================================================================== --- stable/8/crypto/openssh/sshd.c Sat Dec 19 19:30:27 2009 (r200737) +++ stable/8/crypto/openssh/sshd.c Sat Dec 19 19:35:53 2009 (r200738) @@ -47,6 +47,7 @@ __RCSID("$FreeBSD$"); #include #include +#include #include #ifdef HAVE_SYS_STAT_H # include @@ -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) { Modified: stable/8/usr.sbin/cron/cron/cron.c ============================================================================== --- stable/8/usr.sbin/cron/cron/cron.c Sat Dec 19 19:30:27 2009 (r200737) +++ stable/8/usr.sbin/cron/cron/cron.c Sat Dec 19 19:35:53 2009 (r200738) @@ -24,6 +24,7 @@ static const char rcsid[] = #include "cron.h" +#include #include #if SYS_TIME_H # include @@ -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; Modified: stable/8/usr.sbin/inetd/inetd.c ============================================================================== --- stable/8/usr.sbin/inetd/inetd.c Sat Dec 19 19:30:27 2009 (r200737) +++ stable/8/usr.sbin/inetd/inetd.c Sat Dec 19 19:35:53 2009 (r200738) @@ -110,6 +110,7 @@ __FBSDID("$FreeBSD$"); */ #include #include +#include #include #include #include @@ -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]); Modified: stable/8/usr.sbin/syslogd/syslogd.c ============================================================================== --- stable/8/usr.sbin/syslogd/syslogd.c Sat Dec 19 19:30:27 2009 (r200737) +++ stable/8/usr.sbin/syslogd/syslogd.c Sat Dec 19 19:35:53 2009 (r200738) @@ -77,6 +77,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -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)