]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 477] Linux needs larger RLIM_MEMLOCK, from Cristoph Gysin
authorHarlan Stenn <stenn@ntp.org>
Mon, 15 Aug 2005 08:01:26 +0000 (04:01 -0400)
committerHarlan Stenn <stenn@ntp.org>
Mon, 15 Aug 2005 08:01:26 +0000 (04:01 -0400)
bk: 43004bd6et0qsCzRlpMzJ9xxw4ciHg

ntpd/ntpd.c

index 2f4fa00cecf9c54cdf9c85c4ddfec7636b66a3b3..dc0b824064cc21ccef3d8c734d5fecfda50b20e9 100644 (file)
@@ -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 */
        /*