added configure option --disable-accept4 to force netdata use its own version of accept4(); fixes #2591
Costa Tsaousis (ktsaou) committed
Aug 21, 2017 at 15:12 UTC
6cb586f15af38156beaf3ef1492f8fb7a1182d6a
2 files changed
+23
-10
configure.ac
+18
-9
@@ -49,22 +49,28 @@ AC_USE_SYSTEM_EXTENSIONS
49
50
AC_ARG_ENABLE(
51
[plugin-nfacct],
52
- [AS_HELP_STRING([--enable-plugin-nfacct], [enable nfacct plugin, requires root])],
52
+ [AS_HELP_STRING([--enable-plugin-nfacct], [enable nfacct plugin, requires running netdata as root @<:@default disabled@:>@])],
53
,
54
[enable_plugin_nfacct="no"]
55
)
56
AC_ARG_ENABLE(
57
[plugin-freeipmi],
58
- [AS_HELP_STRING([--enable-plugin-freeipmi], [enable freeipmi plugin])],
58
+ [AS_HELP_STRING([--enable-plugin-freeipmi], [enable freeipmi plugin @<:@default autodetect@:>@])],
59
,
60
[enable_plugin_freeipmi="detect"]
61
)
62
AC_ARG_ENABLE(
63
[pedantic],
64
- [AS_HELP_STRING([--enable-pedantic], [enable pedantic compiler warnings])],
64
+ [AS_HELP_STRING([--enable-pedantic], [enable pedantic compiler warnings @<:@default disabled@:>@])],
65
,
66
[enable_pedantic="no"]
67
)
68
+AC_ARG_ENABLE(
69
+ [accept4],
70
+ [AS_HELP_STRING([--disable-accept4], [System does not have accept4 @<:@default autodetect@:>@])],
71
+ ,
72
+ [enable_accept4="detect"]
73
+)
74
AC_ARG_WITH(
75
[webdir],
76
[AS_HELP_STRING([--with-webdir], [location of webdir @<:@PKGDATADIR/web@:>@])],
@@ -73,25 +79,25 @@ AC_ARG_WITH(
79
)
80
AC_ARG_WITH(
81
[libcap],
76
- [AS_HELP_STRING([--with-libcap], [build with libcap])],
82
+ [AS_HELP_STRING([--with-libcap], [build with libcap @<:@default autodetect@:>@])],
83
,
84
[with_libcap="detect"]
85
)
86
AC_ARG_WITH(
87
[zlib],
82
- [AS_HELP_STRING([--with-zlib], [build with zlib])],
88
+ [AS_HELP_STRING([--without-zlib], [build without zlib @<:@default enabled@:>@])],
89
,
90
[with_zlib="yes"]
91
)
92
AC_ARG_WITH(
93
[math],
88
- [AS_HELP_STRING([--with-math], [build with math])],
94
+ [AS_HELP_STRING([--without-math], [build without math @<:@default enabled@:>@])],
95
,
96
[with_math="yes"]
97
)
98
AC_ARG_WITH(
99
[user],
94
- [AS_HELP_STRING([--with-user], [use this user to drop privilege])],
100
+ [AS_HELP_STRING([--with-user], [use this user to drop privilege @<:@default nobody@:>@])],
101
,
102
[with_user="nobody"]
103
)
@@ -103,7 +109,7 @@ AC_ARG_ENABLE(
109
)
110
AC_ARG_ENABLE(
111
[lto],
106
- [AS_HELP_STRING([--disable-lto], [Link Time Optimizations @<:@default enabled@:>@])],
112
+ [AS_HELP_STRING([--disable-lto], [Link Time Optimizations @<:@default autodetect@:>@])],
113
,
114
[enable_lto="detect"]
115
)
@@ -121,7 +127,6 @@ AX_GCC_FUNC_ATTRIBUTE([noreturn])
127
AX_GCC_FUNC_ATTRIBUTE([format])
128
AX_GCC_FUNC_ATTRIBUTE([warn_unused_result])
129
124
-AC_CHECK_FUNCS_ONCE(accept4)
130
AC_CHECK_TYPES([struct timespec, clockid_t], [], [], [[#include <time.h>]])
131
AC_SEARCH_LIBS([clock_gettime], [rt posix4])
132
AC_CHECK_FUNCS([clock_gettime])
@@ -148,6 +153,10 @@ AC_HEADER_RESOLV
153
154
AC_CHECK_HEADERS_ONCE([sys/prctl.h])
155
156
+if test "${enable_accept4}" != "no"; then
157
+ AC_CHECK_FUNCS_ONCE(accept4)
158
+fi
159
+
160
# -----------------------------------------------------------------------------
161
# operating system detection
162
src/socket.c
+5
-1
@@ -747,7 +747,7 @@ int accept_socket(int fd, int flags, char *client_ip, size_t ipsize, char *clien
747
socklen_t addrlen = sizeof(sadr);
748
749
int nfd = accept4(fd, (struct sockaddr *)&sadr, &addrlen, flags);
750
- if (nfd >= 0) {
750
+ if (likely(nfd >= 0)) {
751
if (getnameinfo((struct sockaddr *)&sadr, addrlen, client_ip, (socklen_t)ipsize, client_port, (socklen_t)portsize, NI_NUMERICHOST | NI_NUMERICSERV) != 0) {
752
error("LISTENER: cannot getnameinfo() on received client connection.");
753
strncpyz(client_ip, "UNKNOWN", ipsize - 1);
@@ -775,6 +775,10 @@ int accept_socket(int fd, int flags, char *client_ip, size_t ipsize, char *clien
775
break;
776
}
777
}
778
+#ifdef HAVE_ACCEPT4
779
+ else if(errno == ENOSYS)
780
+ error("netdata has been compiled with the assumption that the system has the accept4() call, but it is not here. Recompile netdata like this: ./configure --disable-accept4 ...");
781
+#endif
782
783
return nfd;
784
}