From: Harlan Stenn Date: Mon, 15 Aug 2005 08:01:26 +0000 (-0400) Subject: [Bug 477] Linux needs larger RLIM_MEMLOCK, from Cristoph Gysin X-Git-Tag: NTP_4_2_0B_RC1~11^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a1a829f40bfb85b9bebe941f70dbc2756bb13a9a;p=thirdparty%2Fntp.git [Bug 477] Linux needs larger RLIM_MEMLOCK, from Cristoph Gysin bk: 43004bd6et0qsCzRlpMzJ9xxw4ciHg --- diff --git a/ntpd/ntpd.c b/ntpd/ntpd.c index 2f4fa00ce..dc0b82406 100644 --- a/ntpd/ntpd.c +++ b/ntpd/ntpd.c @@ -691,6 +691,18 @@ service_main( "Cannot adjust stack limit for mlockall: %m"); } } +# ifdef RLIMIT_MEMLOCK + /* + * The default RLIMIT_MEMLOCK is very low on Linux systems. + * Unless we increase this limit malloc calls are likely to + * fail if we drop root privlege. To be useful the value + * has to be larger than the largest ntpd resident set size. + */ + rl.rlim_cur = rl.rlim_max = 32*1024*1024; + if (setrlimit(RLIMIT_MEMLOCK, &rl) == -1) { + msyslog(LOG_ERR, "Cannot set RLIMIT_MEMLOCK: %m"); + } +# endif /* RLIMIT_MEMLOCK */ } # endif /* HAVE_SETRLIMIT */ /*