[Git][NTPsec/ntpsec][master] 3 commits: Define IGNORE in only one place.

Eric S. Raymond gitlab at mg.gitlab.com
Fri Mar 31 08:26:00 UTC 2017


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
307453a5 by Eric S. Raymond at 2017-03-31T04:25:13-04:00
Define IGNORE in only one place.

- - - - -
f53b4ee5 by Eric S. Raymond at 2017-03-31T04:25:13-04:00
Assume POSIXness - in particular, that sysconf(_SC_OPEN_MAX) works.

- - - - -
9768cdfe by Eric S. Raymond at 2017-03-31T04:25:13-04:00
No longer trying for getdtableize(); simplify configuration.

- - - - -


7 changed files:

- include/libntp.h
- include/ntp_io.h
- include/ntp_stdlib.h
- libntp/ntp_worker.c
- libntp/socket.c
- ntpd/ntp_util.c
- wafhelpers/configure.py


Changes:

=====================================
include/libntp.h
=====================================
--- a/include/libntp.h
+++ b/include/libntp.h
@@ -1,16 +1,4 @@
 /* libntp.h */
 
-#if defined(_SC_OPEN_MAX)
-#define GETDTABLESIZE()	((int)sysconf(_SC_OPEN_MAX))
-#elif defined(HAVE_GETDTABLESIZE)
-#define GETDTABLESIZE	getdtablesize
-#else
-/*
- * if we have no idea about the max fd value set up things
- * so we will start at FOPEN_MAX
- */
-#define GETDTABLESIZE()	(FOPEN_MAX + FD_CHUNK)
-#endif
-
 extern void	make_socket_nonblocking( SOCKET fd );
 extern SOCKET	move_fd( SOCKET fd );


=====================================
include/ntp_io.h
=====================================
--- a/include/ntp_io.h
+++ b/include/ntp_io.h
@@ -48,7 +48,4 @@ extern void	add_nic_rule(nic_rule_match match_type,
 			     nic_rule_action action);
 extern	void	maintain_activefds(int fd, int closing);
 
-/* hack to ignore GCC Unused Result */
-#define IGNORE(r) do{if(r){}}while(0)
-
 #endif	/* GUARD_NTP_IO_H */


=====================================
include/ntp_stdlib.h
=====================================
--- a/include/ntp_stdlib.h
+++ b/include/ntp_stdlib.h
@@ -217,6 +217,9 @@ extern bool	trunc_os_clock;		/* sys_tick > measured_tick */
 #define COMPARE_EQUAL		0
 #define COMPARE_LESSTHAN	-1
 
+/* hack to ignore GCC Unused Result */
+#define IGNORE(r) do{if(r){}}while(0)
+
 extern bool sandbox(const bool droproot, char *user, const char *group,
 	     const char *chrootdir, bool want_dynamic_interface_tracking);
 


=====================================
libntp/ntp_worker.c
=====================================
--- a/libntp/ntp_worker.c
+++ b/libntp/ntp_worker.c
@@ -111,7 +111,7 @@ close_all_beyond(
 	int max_fd;
 
 	/* includes POSIX case */
-	max_fd = GETDTABLESIZE();
+	max_fd = sysconf(_SC_OPEN_MAX);
 	for (fd = keep_fd + 1; fd < max_fd; fd++)
 		close(fd);
 # endif	/* !HAVE_CLOSEFROM && !F_CLOSEM */


=====================================
libntp/socket.c
=====================================
--- a/libntp/socket.c
+++ b/libntp/socket.c
@@ -24,7 +24,7 @@
  * and may exceed the current file descriptor limits.
  * We are using following strategy:
  * - keep a current socket fd boundary initialized with
- *   max(0, min(GETDTABLESIZE() - FD_CHUNK, FOPEN_MAX))
+ *   max(0, min(sysconf(_SC_OPEN_MAX) - FD_CHUNK, FOPEN_MAX))
  * - attempt to move the descriptor to the boundary or
  *   above.
  *   - if that fails and boundary > 0 set boundary
@@ -77,11 +77,11 @@ move_fd(
 	 * already
 	 */
 	if (socket_boundary == -1) {
-		socket_boundary = max(0, min(GETDTABLESIZE() - FD_CHUNK,
+		socket_boundary = max(0, min(sysconf(_SC_OPEN_MAX) - FD_CHUNK,
 					     min(FOPEN_MAX, FD_PREFERRED_SOCKBOUNDARY)));
 		TRACE(1, ("move_fd: estimated max descriptors: %d, "
 			  "initial socket boundary: %d\n",
-			  GETDTABLESIZE(), socket_boundary));
+			  (int)sysconf(_SC_OPEN_MAX), socket_boundary));
 	}
 
 	/*


=====================================
ntpd/ntp_util.c
=====================================
--- a/ntpd/ntp_util.c
+++ b/ntpd/ntp_util.c
@@ -10,6 +10,7 @@
 #include "ntp_filegen.h"
 #include "ntp_leapsec.h"
 #include "ntp_stdlib.h"
+#include "ntp_stdlib.h"
 #include "ntpd.h"
 #include "timespecops.h"
 
@@ -145,8 +146,6 @@ init_util(void)
 /*
  * hourly_stats - print some interesting stats
  */
-#define IGNORE(r) do{if(r){}}while(0)
-
 static void drift_write(char *driftfile, double drift)
 {
 	int fd;


=====================================
wafhelpers/configure.py
=====================================
--- a/wafhelpers/configure.py
+++ b/wafhelpers/configure.py
@@ -496,7 +496,6 @@ int main(int argc, char **argv) {
         ('closefrom', ["stdlib.h"]),
         ('clock_gettime', ["time.h"], "RT"),
         ('clock_settime', ["time.h"], "RT"),
-        ('getdtablesize', ["unistd.h"]),
         ('getrusage', ["sys/time.h", "sys/resource.h"]),
         ('ntp_adjtime', ["sys/time.h", "sys/timex.h"]),     # BSD
         ('ntp_gettime', ["sys/time.h", "sys/timex.h"]),     # BSD



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/2b61cbf091a8f1c68f90dbc5f935d975f9b7ccb0...9768cdfee63c4100e2af0bd0b2591307e4def143
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170331/41265305/attachment.html>


More information about the vc mailing list