From: Harlan Stenn Date: Thu, 8 Aug 2013 08:18:46 +0000 (-0400) Subject: [Bug 2454] Need way to set file descriptor limit - cleanup X-Git-Tag: NTP_4_2_7P382~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=816fda15d64fbc57d9aca85f7e695c0f631270f4;p=thirdparty%2Fntp.git [Bug 2454] Need way to set file descriptor limit - cleanup bk: 52035466riJ6I6h15MVUsK-FoKRLcw --- diff --git a/ChangeLog b/ChangeLog index 1584357eb..36be41593 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,11 @@ +* [Bug 2454] Need way to set file descriptor limit - cleanup. (4.2.7p381) 2013/08/07 Released by Harlan Stenn * [Bug 2451] rlimit command is missing from the table of contents in miscopt.html . * [Bug 2452] provide io_handler/input_handler only on non HAVE_IO_COMPLETION_PORT platforms -* [Bug 2453] Need a way to avoid calling mlockall. -* [Bug 2454] Need way to set file descriptor limit. +* [Bug 2453] Need a way to avoid calling mlockall. +* [Bug 2454] Need way to set file descriptor limit. * [Bug 2458] AM_CONFIG_HEADER is obsolete. (4.2.7p380) 2013/08/03 Released by Harlan Stenn * CID 984511: Some systems have different printf needs for sizeof. @@ -1306,15 +1307,15 @@ * Documentation nit cleanup. * Documentation updates from Dave Mills. (4.2.7p62) 2010/10/12 Released by Harlan Stenn -* [Bug 750] from 4.2.6p3-RC3: Non-existing device causes coredump with +* [Bug 750] from 4.2.6p3-RC3: Non-existing device causes coredump with RIPE-NCC driver. * [Bug 1567] from 4.2.6p3-RC3: Support Arbiter 1093C Satellite Clock on Windows. * [Bug 1581] from 4.2.6p3-RC3: printf format string mismatch leftover. * [Bug 1659] from 4.2.6p3-RC3: Support Truetime Satellite Clocks on - Windows. + Windows. * [Bug 1660] from 4.2.6p3-RC3: On some systems, test is in /usr/bin, not - /bin. + /bin. * [Bug 1661] from 4.2.6p3-RC3: Re-indent refclock_ripencc.c. * Lose peer_count from ntp_peer.c and ntp_proto.c (Dave Mills). * Documentation updates from Dave Mills. @@ -1478,7 +1479,7 @@ (4.2.7p25) 2010/04/20 Released by Harlan Stenn * [Bug 1528] from 4.2.6p2-RC2: Remove --with-arlib from br-flock. * [Bug 1503] [Bug 1504] [Bug 1518] [Bug 1522] from 4.2.6p2-RC2: - all of which were fixed in 4.2.7 previously. + all of which were fixed in 4.2.7 previously. (4.2.7p24) 2010/04/13 Released by Harlan Stenn * [Bug 1390] Control PPS on the Oncore M12. * [Bug 1518] Windows ntpd should lock to one processor more @@ -1608,7 +1609,7 @@ * [Bug 1479] from 4.2.6p1-RC5: not finding readline headers. * [Bug 1484] from 4.2.6p1-RC5: ushort is not defined in QNX6. (4.2.7p18) 2010/02/07 Released by Harlan Stenn -* [Bug 1480] from 4.2.6p1-RC5: snprintf() cleanup caused +* [Bug 1480] from 4.2.6p1-RC5: snprintf() cleanup caused unterminated refclock IDs. * Stop using getaddrinfo() to convert numeric address strings to on-wire addresses in favor of is_ip_address() alone. @@ -2273,7 +2274,7 @@ display both build and runtime OpenSSL versions when they differ. * add wildcard match class for interface/nic rules. * fix mistaken carryover of prefixlen from one rule to the next. * Ensure IPv6 localhost address ::1 is included in libisc's Windows IPv6 - address enumeration, allowing ntpq and ntpdc's hardcoding to 127.0.0.1 + address enumeration, allowing ntpq and ntpdc's hardcoding to 127.0.0.1 on Windows to end. (4.2.5p218) 2009/09/21 Released by Harlan Stenn * [Bug 1314] saveconfig emits -4 and -6 on when not given. @@ -2384,7 +2385,7 @@ display both build and runtime OpenSSL versions when they differ. (4.2.5p193) 2009/07/25 Released by Harlan Stenn * [Bug 1261] CID 34: simulate_server() rbuf.msg_flags uninitialized. * [Bug 1262] CID 35: xpkt.mac uninitialized in simulate_server(). -* [Bug 1263] CID 37: CID 38: CID 40: CID 43: multiple refclocks +* [Bug 1263] CID 37: CID 38: CID 40: CID 43: multiple refclocks uninitialized tm_zone (arc, chronolog, dumbclock, pcf). * [Bug 1264] CID 64: gsoc_sntp on_wire() frees wrong ptr receiving KoD. * [Bug 1265] CID 65: CID 66: gsoc_sntp on_wire() leaks x_pkt, r_pkt. @@ -2401,7 +2402,7 @@ display both build and runtime OpenSSL versions when they differ. * [Bug 1250] CID 53: kod_init_kod_db() overruns kod_db malloc'd buffer. * [Bug 1251] CID 68: search_entry() mishandles dst argument. * [Bug 1252] CID 32: Quiet Coverity warning with assertion. -* [Bug 1253] CID 50: gsoc_sntp/crypto.c auth_init() always returns a +* [Bug 1253] CID 50: gsoc_sntp/crypto.c auth_init() always returns a list with one entry. * [Bug 1254] CID 56: tv_to_str() leaks a struct tm each call. * [Bug 1255] CID 55: pkt_output() leaks a copy of each packet. @@ -2880,7 +2881,7 @@ display both build and runtime OpenSSL versions when they differ. --- (4.2.4p6) 2009/01/08 Released by Harlan Stenn -* [Bug 1113] Fixed build errors with recent versions of openSSL. +* [Bug 1113] Fixed build errors with recent versions of openSSL. * [Sec 1111] Fix incorrect check of EVP_VerifyFinal()'s return value. * Update the copyright year. @@ -2949,9 +2950,9 @@ display both build and runtime OpenSSL versions when they differ. * Update bugreport URL. * Update -I documentation. * [Bug 713] Fix bug reporting information. -* A bug in the application of the negative-sawtooth for 12 channel receivers. +* A bug in the application of the negative-sawtooth for 12 channel receivers. * The removal of unneeded startup code used for the original LinuxPPS, it now - conforms to the PPSAPI and does not need special code. + conforms to the PPSAPI and does not need special code. * ntp-keygen.c: Coverity fixes [CID 33,47]. * Volley cleanup from Dave Mills. * Fuzz cleanup from Dave Mills. @@ -2959,7 +2960,7 @@ display both build and runtime OpenSSL versions when they differ. * ntpsim.c: add missing protypes and fix [CID 34], a nit. * Upgraded bison at UDel. * Update br-flock and flock-build machine lists. -* [Bug 752] QoS: add parse/config handling code. +* [Bug 752] QoS: add parse/config handling code. * Fix the #include order in tickadj.c for picky machines. * [Bug 752] QoS: On some systems, netinet/ip.h needs netinet/ip_systm.h. * [Bug 752] Update the QoS tagging (code only - configuration to follow). diff --git a/html/miscopt.html b/html/miscopt.html index 28fe2145c..6e5fefb88 100644 --- a/html/miscopt.html +++ b/html/miscopt.html @@ -120,15 +120,15 @@
Specifies the stepout threshold in seconds. The default without this command is 300 s. Since this option also affects the training and startup intervals, it should not be set less than the default. Further details are on the Clock State Machine page.
-
rlimit [memlock Nmegabytes | stacklimit N4kPages]
+
rlimit [memlock Nmegabytes | stacksize N4kPages | filenum Nfiledescriptors]
This command alters certain process storage allocation limits, and is only available on some operating systems. Options are are as follows:
memlock Nmegabytes
Specify the number of megabytes of memory that can be allocated. Probably only available under Linux, this option is useful when dropping root (the -i option). The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory.
-
stacklimit N4kPages
+
stacksize N4kPages
Specifies the maximum size of the process stack on systems with the mlockall() function. Defaults to 50 4k pages (200 4k pages in OpenBSD).
-
filenum N4kPages
+
filenum Nfiledescriptors
Specifies the maximum number of file descriptors ntp may have open at the same time. Defaults to system default.
diff --git a/include/ntp_config.h b/include/ntp_config.h index 982594e4c..900688cef 100644 --- a/include/ntp_config.h +++ b/include/ntp_config.h @@ -315,7 +315,7 @@ int dump_config_tree(config_tree *ptree, FILE *df, int comment); int dump_all_config_trees(FILE *df, int comment); #endif -#if defined(HAVE_MLOCKALL) && defined(HAVE_SETRLIMIT) +#if defined(HAVE_SETRLIMIT) void ntp_rlimit(int, rlim_t, int, char *); #endif diff --git a/ntpd/invoke-ntp.conf.texi b/ntpd/invoke-ntp.conf.texi index ebb1ba722..47d395458 100644 --- a/ntpd/invoke-ntp.conf.texi +++ b/ntpd/invoke-ntp.conf.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (invoke-ntp.conf.texi) # -# It has been AutoGen-ed August 7, 2013 at 11:41:56 AM by AutoGen 5.18.1pre3 +# It has been AutoGen-ed August 8, 2013 at 04:15:35 AM by AutoGen 5.18.1pre3 # From the definitions ntp.conf.def # and the template file agtexi-file.tpl @end ignore @@ -2631,7 +2631,7 @@ be set to any positive number in seconds. If set to zero, the stepout pulses will not be suppressed. @end table -@item @code{rlimit}Oo@code{memlock} @kbd{Nmegabytes} |@code{stacklimit} @kbd{N4kPages}@code{filenum} @kbd{Nfiledescriptors}Oc +@item @code{rlimit}Oo@code{memlock} @kbd{Nmegabytes} |@code{stacksize} @kbd{N4kPages}@code{filenum} @kbd{Nfiledescriptors}Oc @table @asis @item @code{memlock} @kbd{Nmegabytes} @@ -2641,7 +2641,7 @@ when dropping root (the @code{-i} option). The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory. -@item @code{stacklimit} @kbd{N4kPages} +@item @code{stacksize} @kbd{N4kPages} Specifies the maximum size of the process stack on systems with the @item @code{filenum} @kbd{Nfiledescriptors} Specifies the maximum number of file descriptors ntpd may have open at once. Defaults to the system default. diff --git a/ntpd/ntp.conf.5man b/ntpd/ntp.conf.5man index 6a5549bfb..8982e75f4 100644 --- a/ntpd/ntp.conf.5man +++ b/ntpd/ntp.conf.5man @@ -1,8 +1,8 @@ -.TH ntp.conf 5man "07 Aug 2013" "4.2.7p381" "File Formats" +.TH ntp.conf 5man "08 Aug 2013" "4.2.7p381" "File Formats" .\" .\" EDIT THIS FILE WITH CAUTION (ntp.man) .\" -.\" It has been AutoGen-ed August 7, 2013 at 11:41:41 AM by AutoGen 5.18.1pre3 +.\" It has been AutoGen-ed August 8, 2013 at 04:15:29 AM by AutoGen 5.18.1pre3 .\" From the definitions ntp.conf.def .\" and the template file agman-cmd.tpl .\" @@ -2824,7 +2824,7 @@ pulses will not be suppressed. .BR Xo Ic rlimit .Oo .Cm memlock Ar Nmegabytes | -.Cm stacklimit Ar N4kPages +.Cm stacksize Ar N4kPages .Cm filenum Ar Nfiledescriptors .Oc .Xc @@ -2838,7 +2838,7 @@ when dropping root (the option). The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory. .ti -4 -.IR Cm stacklimit Ar N4kPages +.IR Cm stacksize Ar N4kPages Specifies the maximum size of the process stack on systems with the .ti -4 .IR Cm filenum Ar Nfiledescriptors diff --git a/ntpd/ntp.conf.5mdoc b/ntpd/ntp.conf.5mdoc index a1ab4b927..986ea79d5 100644 --- a/ntpd/ntp.conf.5mdoc +++ b/ntpd/ntp.conf.5mdoc @@ -1,9 +1,9 @@ -.Dd August 7 2013 +.Dd August 8 2013 .Dt NTP_CONF 5mdoc File Formats .Os SunOS 5.10 .\" EDIT THIS FILE WITH CAUTION (ntp.mdoc) .\" -.\" It has been AutoGen-ed August 7, 2013 at 11:42:01 AM by AutoGen 5.18.1pre3 +.\" It has been AutoGen-ed August 8, 2013 at 04:15:37 AM by AutoGen 5.18.1pre3 .\" From the definitions ntp.conf.def .\" and the template file agmdoc-cmd.tpl .Sh NAME @@ -2660,7 +2660,7 @@ pulses will not be suppressed. .It Xo Ic rlimit .Oo .Cm memlock Ar Nmegabytes | -.Cm stacklimit Ar N4kPages +.Cm stacksize Ar N4kPages .Cm filenum Ar Nfiledescriptors .Oc .Xc @@ -2672,7 +2672,7 @@ when dropping root (the .Fl i option). The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory. -.It Cm stacklimit Ar N4kPages +.It Cm stacksize Ar N4kPages Specifies the maximum size of the process stack on systems with the .It Cm filenum Ar Nfiledescriptors Specifies the maximum number of file descriptors ntpd may have open at once. Defaults to the system default. diff --git a/ntpd/ntp.conf.def b/ntpd/ntp.conf.def index 8fd3629ae..cd3d6a10f 100644 --- a/ntpd/ntp.conf.def +++ b/ntpd/ntp.conf.def @@ -2662,7 +2662,7 @@ pulses will not be suppressed. .It Xo Ic rlimit .Oo .Cm memlock Ar Nmegabytes | -.Cm stacklimit Ar N4kPages +.Cm stacksize Ar N4kPages .Cm filenum Ar Nfiledescriptors .Oc .Xc @@ -2674,7 +2674,7 @@ when dropping root (the .Fl i option). The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory. -.It Cm stacklimit Ar N4kPages +.It Cm stacksize Ar N4kPages Specifies the maximum size of the process stack on systems with the .It Cm filenum Ar Nfiledescriptors Specifies the maximum number of file descriptors ntpd may have open at once. Defaults to the system default. diff --git a/ntpd/ntp.conf.man.in b/ntpd/ntp.conf.man.in index 63c009cd0..ce3576267 100644 --- a/ntpd/ntp.conf.man.in +++ b/ntpd/ntp.conf.man.in @@ -1,8 +1,8 @@ -.TH ntp.conf 5 "07 Aug 2013" "4.2.7p381" "File Formats" +.TH ntp.conf 5 "08 Aug 2013" "4.2.7p381" "File Formats" .\" .\" EDIT THIS FILE WITH CAUTION (ntp.man) .\" -.\" It has been AutoGen-ed August 7, 2013 at 11:41:41 AM by AutoGen 5.18.1pre3 +.\" It has been AutoGen-ed August 8, 2013 at 04:15:29 AM by AutoGen 5.18.1pre3 .\" From the definitions ntp.conf.def .\" and the template file agman-cmd.tpl .\" @@ -2824,7 +2824,7 @@ pulses will not be suppressed. .BR Xo Ic rlimit .Oo .Cm memlock Ar Nmegabytes | -.Cm stacklimit Ar N4kPages +.Cm stacksize Ar N4kPages .Cm filenum Ar Nfiledescriptors .Oc .Xc @@ -2838,7 +2838,7 @@ when dropping root (the option). The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory. .ti -4 -.IR Cm stacklimit Ar N4kPages +.IR Cm stacksize Ar N4kPages Specifies the maximum size of the process stack on systems with the .ti -4 .IR Cm filenum Ar Nfiledescriptors diff --git a/ntpd/ntp.conf.mdoc.in b/ntpd/ntp.conf.mdoc.in index d95fc82b0..20c2e7d18 100644 --- a/ntpd/ntp.conf.mdoc.in +++ b/ntpd/ntp.conf.mdoc.in @@ -1,9 +1,9 @@ -.Dd August 7 2013 +.Dd August 8 2013 .Dt NTP_CONF 5 File Formats .Os SunOS 5.10 .\" EDIT THIS FILE WITH CAUTION (ntp.mdoc) .\" -.\" It has been AutoGen-ed August 7, 2013 at 11:42:01 AM by AutoGen 5.18.1pre3 +.\" It has been AutoGen-ed August 8, 2013 at 04:15:37 AM by AutoGen 5.18.1pre3 .\" From the definitions ntp.conf.def .\" and the template file agmdoc-cmd.tpl .Sh NAME @@ -2660,7 +2660,7 @@ pulses will not be suppressed. .It Xo Ic rlimit .Oo .Cm memlock Ar Nmegabytes | -.Cm stacklimit Ar N4kPages +.Cm stacksize Ar N4kPages .Cm filenum Ar Nfiledescriptors .Oc .Xc @@ -2672,7 +2672,7 @@ when dropping root (the .Fl i option). The default is 32 megabytes. Setting this to zero will prevent any attemp to lock memory. -.It Cm stacklimit Ar N4kPages +.It Cm stacksize Ar N4kPages Specifies the maximum size of the process stack on systems with the .It Cm filenum Ar Nfiledescriptors Specifies the maximum number of file descriptors ntpd may have open at once. Defaults to the system default. diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c index 5cb6d2c22..3ae71a9b4 100644 --- a/ntpd/ntp_config.c +++ b/ntpd/ntp_config.c @@ -2606,7 +2606,7 @@ config_rlimit( case T_Memlock: if (rlimit_av->value.i != 0) { -#if defined(HAVE_MLOCKALL) && defined(RLIMIT_MEMLOCK) +#if defined(RLIMIT_MEMLOCK) ntp_rlimit(RLIMIT_MEMLOCK, (rlim_t)(rlimit_av->value.i * 1024 * 1024), 1024 * 1024, @@ -2614,14 +2614,14 @@ config_rlimit( #else /* STDERR as well would be fine... */ msyslog(LOG_WARNING, "'rlimit memlock' specified but is not available on this system."); -#endif /* !(HAVE_MLOCKALL && RLIMIT_MEMLOCK) */ +#endif /* RLIMIT_MEMLOCK */ } else { do_memlock = 0; } break; case T_Stacksize: -#if defined(HAVE_MLOCKALL) && defined(RLIMIT_STACK) +#if defined(RLIMIT_STACK) ntp_rlimit(RLIMIT_STACK, (rlim_t)(rlimit_av->value.i * 4096), 4096, @@ -2629,7 +2629,7 @@ config_rlimit( #else /* STDERR as well would be fine... */ msyslog(LOG_WARNING, "'rlimit stacksize' specified but is not available on this system."); -#endif /* !(HAVE_MLOCKALL && RLIMIT_STACK) */ +#endif /* RLIMIT_STACK */ break; case T_Filenum: @@ -2641,7 +2641,7 @@ config_rlimit( #else /* STDERR as well would be fine... */ msyslog(LOG_WARNING, "'rlimit filenum' specified but is not available on this system."); -#endif /* !(RLIMIT_NOFILE) */ +#endif /* RLIMIT_NOFILE */ break; } @@ -4861,7 +4861,7 @@ getnetnum( } #endif /* !SIM */ -# if defined(HAVE_MLOCKALL) && defined(HAVE_SETRLIMIT) +#if defined(HAVE_SETRLIMIT) void ntp_rlimit( int rl_what, @@ -4873,7 +4873,7 @@ ntp_rlimit( struct rlimit rl; switch (rl_what) { -#ifdef RLIMIT_MEMLOCK +# ifdef RLIMIT_MEMLOCK case RLIMIT_MEMLOCK: /* * The default RLIMIT_MEMLOCK is very low on Linux systems. @@ -4887,9 +4887,9 @@ ntp_rlimit( if (setrlimit(RLIMIT_MEMLOCK, &rl) == -1) msyslog(LOG_ERR, "Cannot set RLIMIT_MEMLOCK: %m"); break; -#endif /* RLIMIT_MEMLOCK */ +# endif /* RLIMIT_MEMLOCK */ -#ifdef RLIMIT_NOFILE +# ifdef RLIMIT_NOFILE case RLIMIT_NOFILE: /* * For large systems the default file descriptor limit may @@ -4901,8 +4901,9 @@ ntp_rlimit( if (setrlimit(RLIMIT_NOFILE, &rl) == -1) msyslog(LOG_ERR, "Cannot set RLIMIT_NOFILE: %m"); break; -#endif /* RLIMIT_NOFILE */ +# endif /* RLIMIT_NOFILE */ +# ifdef RLIMIT_STACK case RLIMIT_STACK: /* * Provide a way to set the stack limit to something @@ -4927,10 +4928,11 @@ ntp_rlimit( } } break; +# endif /* RLIMIT_STACK */ default: INSIST(!"Unexpected setrlimit() case!"); break; } } -# endif /* ... && HAVE_SETRLIMIT */ +#endif /* HAVE_SETRLIMIT */