make zlib compulsory dep (#14928)
zlib compulsory
Timotej S committed
May 10, 2023 at 17:30 UTC
4ff305a4ad5e77367eeffa3d58564dcfb6e4e6e8
10 files changed
+8
-76
CMakeLists.txt
-1
@@ -86,7 +86,6 @@ pkg_check_modules(ZLIB REQUIRED zlib)
86
set(NETDATA_COMMON_CFLAGS ${NETDATA_COMMON_CFLAGS} ${ZLIB_CFLAGS_OTHER})
87
set(NETDATA_COMMON_LIBRARIES ${NETDATA_COMMON_LIBRARIES} ${ZLIB_LIBRARIES})
88
set(NETDATA_COMMON_INCLUDE_DIRS ${NETDATA_COMMON_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS})
89
-# set(NETDATA_REQUIRED_DEFINES "${NETDATA_REQUIRED_DEFINES} -DNETDATA_WITH_ZLIB=1")
89
90
# -----------------------------------------------------------------------------
91
# libuv multi-platform support library with a focus on asynchronous I/O
Makefile.am
+2
-2
@@ -118,7 +118,7 @@ SUBDIRS += \
118
AM_CFLAGS = \
119
$(OPTIONAL_MATH_CFLAGS) \
120
$(OPTIONAL_NFACCT_CFLAGS) \
121
- $(OPTIONAL_ZLIB_CFLAGS) \
121
+ $(ZLIB_CFLAGS) \
122
$(OPTIONAL_UUID_CFLAGS) \
123
$(OPTIONAL_MQTT_CFLAGS) \
124
$(OPTIONAL_LIBCAP_LIBS) \
@@ -1108,7 +1108,7 @@ endif
1108
NETDATA_COMMON_LIBS = \
1109
$(OPTIONAL_MATH_LIBS) \
1110
$(OPTIONAL_BPF_LIBS) \
1111
- $(OPTIONAL_ZLIB_LIBS) \
1111
+ $(ZLIB_LIBS) \
1112
$(OPTIONAL_SSL_LIBS) \
1113
$(OPTIONAL_UUID_LIBS) \
1114
$(OPTIONAL_MQTT_LIBS) \
aclk/aclk_query.c
-10
@@ -95,11 +95,9 @@ static int http_api_v2(struct aclk_query_thread *query_thr, aclk_query_t query)
95
size_t size = 0;
96
size_t sent = 0;
97
98
-#ifdef NETDATA_WITH_ZLIB
98
int z_ret;
99
BUFFER *z_buffer = buffer_create(NETDATA_WEB_RESPONSE_INITIAL_SIZE, &netdata_buffers_statistics.buffers_aclk);
100
char *start, *end;
102
-#endif
101
102
struct web_client *w = web_client_get_from_cache();
103
w->acl = WEB_CLIENT_ACL_ACLK;
@@ -152,7 +150,6 @@ static int http_api_v2(struct aclk_query_thread *query_thr, aclk_query_t query)
150
size = w->response.data->len;
151
sent = size;
152
155
-#ifdef NETDATA_WITH_ZLIB
153
// check if gzip encoding can and should be used
154
if ((start = strstr((char *)query->data.http_api_v2.payload, WEB_HDR_ACCEPT_ENC))) {
155
start += strlen(WEB_HDR_ACCEPT_ENC);
@@ -199,7 +196,6 @@ static int http_api_v2(struct aclk_query_thread *query_thr, aclk_query_t query)
196
w->response.data = z_buffer;
197
z_buffer = NULL;
198
}
202
-#endif
199
200
w->response.data->date = w->timings.tv_ready.tv_sec;
201
web_client_build_http_header(w);
@@ -209,18 +205,14 @@ static int http_api_v2(struct aclk_query_thread *query_thr, aclk_query_t query)
205
buffer_strcat(local_buffer, w->response.header_output->buffer);
206
207
if (w->response.data->len) {
212
-#ifdef NETDATA_WITH_ZLIB
208
if (w->response.zinitialized) {
209
buffer_need_bytes(local_buffer, w->response.data->len);
210
memcpy(&local_buffer->buffer[local_buffer->len], w->response.data->buffer, w->response.data->len);
211
local_buffer->len += w->response.data->len;
212
sent = sent - size + w->response.data->len;
213
} else {
219
-#endif
214
buffer_strcat(local_buffer, w->response.data->buffer);
221
-#ifdef NETDATA_WITH_ZLIB
215
}
223
-#endif
216
}
217
218
// send msg.
@@ -249,9 +241,7 @@ cleanup:
241
242
pending_req_list_rm(query->msg_id);
243
252
-#ifdef NETDATA_WITH_ZLIB
244
buffer_free(z_buffer);
254
-#endif
245
buffer_free(local_buffer);
246
return retval;
247
}
config.cmake.h.in
-1
@@ -35,7 +35,6 @@
35
#cmakedefine ENABLE_PROMETHEUS_REMOTE_WRITE
36
37
/* they are defined as REQUIRED in CMakeLists.txt */
38
-#define NETDATA_WITH_ZLIB 1
38
#define ENABLE_JSONC 1
39
40
#cmakedefine ENABLE_ML
configure.ac
+4
-23
@@ -129,12 +129,6 @@ AC_ARG_WITH(
129
,
130
[with_libcap="detect"]
131
)
132
-AC_ARG_WITH(
133
- [zlib],
134
- [AS_HELP_STRING([--without-zlib], [build without zlib @<:@default enabled@:>@])],
135
- ,
136
- [with_zlib="yes"]
137
-)
132
AC_ARG_WITH(
133
[math],
134
[AS_HELP_STRING([--without-math], [build without math @<:@default enabled@:>@])],
@@ -481,19 +475,7 @@ PKG_CHECK_MODULES(
475
[have_zlib=yes],
476
[have_zlib=no]
477
)
484
-test "${with_zlib}" = "yes" -a "${have_zlib}" != "yes" && AC_MSG_ERROR([zlib required but not found. Try installing 'zlib1g-dev' or 'zlib-devel'.])
485
-
486
-AC_MSG_CHECKING([if zlib should be used])
487
-if test "${with_zlib}" != "no" -a "${have_zlib}" = "yes"; then
488
- with_zlib="yes"
489
- AC_DEFINE([NETDATA_WITH_ZLIB], [1], [zlib usability])
490
- OPTIONAL_ZLIB_CFLAGS="${ZLIB_CFLAGS}"
491
- OPTIONAL_ZLIB_LIBS="${ZLIB_LIBS}"
492
-else
493
- with_zlib="no"
494
-fi
495
-AC_MSG_RESULT([${with_zlib}])
496
-
478
+test "${have_zlib}" != "yes" && AC_MSG_ERROR([zlib required but not found. Try installing 'zlib1g-dev' or 'zlib-devel'.])
479
480
# -----------------------------------------------------------------------------
481
# libuuid
@@ -1723,7 +1705,7 @@ AC_SUBST([netdata_user])
1705
AC_SUBST([libsysdir])
1706
1707
CFLAGS="${originalCFLAGS} ${OPTIONAL_LTO_CFLAGS} ${OPTIONAL_PROTOBUF_CFLAGS} ${OPTIONAL_MATH_CFLAGS} ${OPTIONAL_NFACCT_CFLAGS} \
1726
- ${OPTIONAL_ZLIB_CFLAGS} ${OPTIONAL_UUID_CFLAGS} \
1708
+ ${ZLIB_CFLAGS} ${OPTIONAL_UUID_CFLAGS} \
1709
${OPTIONAL_LIBCAP_CFLAGS} ${OPTIONAL_IPMIMONITORING_CFLAGS} ${OPTIONAL_CUPS_CFLAGS} ${OPTIONAL_XENSTAT_FLAGS} \
1710
${OPTIONAL_KINESIS_CFLAGS} ${OPTIONAL_PUBSUB_CFLAGS} ${OPTIONAL_PROMETHEUS_REMOTE_WRITE_CFLAGS} \
1711
${OPTIONAL_MONGOC_CFLAGS} ${LWS_CFLAGS} ${OPTIONAL_JSONC_STATIC_CFLAGS} ${OPTIONAL_YAML_STATIC_CFLAGS} ${OPTIONAL_BPF_CFLAGS} ${JUDY_CFLAGS} \
@@ -1752,8 +1734,8 @@ AC_SUBST([OPTIONAL_JSONC_LIBS])
1734
AC_SUBST([OPTIONAL_YAML_LIBS])
1735
AC_SUBST([OPTIONAL_NFACCT_CFLAGS])
1736
AC_SUBST([OPTIONAL_NFACCT_LIBS])
1755
-AC_SUBST([OPTIONAL_ZLIB_CFLAGS])
1756
-AC_SUBST([OPTIONAL_ZLIB_LIBS])
1737
+AC_SUBST([ZLIB_CFLAGS])
1738
+AC_SUBST([ZLIB_LIBS])
1739
AC_SUBST([OPTIONAL_UUID_CFLAGS])
1740
AC_SUBST([OPTIONAL_UUID_LIBS])
1741
AC_SUBST([OPTIONAL_BPF_CFLAGS])
@@ -1934,4 +1916,3 @@ AC_CONFIG_FILES([
1916
AC_OUTPUT
1917
1918
test "${with_math}" != "yes" && AC_MSG_WARN([You are building without math. math allows accurate calculations. It should be enabled.]) || :
1937
-test "${with_zlib}" != "yes" && AC_MSG_WARN([You are building without zlib. zlib allows netdata to transfer a lot less data with web clients. It should be enabled.]) || :
daemon/buildinfo.c
+2
-10
@@ -95,12 +95,6 @@
95
#define FEAT_LIBCAP 0
96
#endif
97
98
-#ifdef NETDATA_WITH_ZLIB
99
-#define FEAT_ZLIB 1
100
-#else
101
-#define FEAT_ZLIB 0
102
-#endif
103
-
98
#ifdef STORAGE_WITH_MATH
99
#define FEAT_LIBM 1
100
#else
@@ -291,7 +285,7 @@ void print_build_info(void) {
285
printf(" libcrypto: %s\n", FEAT_YES_NO(FEAT_CRYPTO));
286
printf(" libm: %s\n", FEAT_YES_NO(FEAT_LIBM));
287
printf(" tcalloc: %s\n", FEAT_YES_NO(FEAT_TCMALLOC));
294
- printf(" zlib: %s\n", FEAT_YES_NO(FEAT_ZLIB));
288
+ printf(" zlib: %s\n", FEAT_YES_NO(1));
289
290
printf("Plugins:\n");
291
printf(" apps: %s\n", FEAT_YES_NO(FEAT_APPS_PLUGIN));
@@ -348,7 +342,7 @@ void print_build_info_json(void) {
342
printf(" \"libcrypto\": %s,\n", FEAT_JSON_BOOL(FEAT_CRYPTO));
343
printf(" \"libm\": %s,\n", FEAT_JSON_BOOL(FEAT_LIBM));
344
printf(" \"tcmalloc\": %s,\n", FEAT_JSON_BOOL(FEAT_TCMALLOC));
351
- printf(" \"zlib\": %s\n", FEAT_JSON_BOOL(FEAT_ZLIB));
345
+ printf(" \"zlib\": %s\n", FEAT_JSON_BOOL(1));
346
printf(" },\n");
347
348
printf(" \"plugins\": {\n");
@@ -425,9 +419,7 @@ void analytics_build_info(BUFFER *b) {
419
#ifdef ENABLE_TCMALLOC
420
add_to_bi(b, "tcalloc");
421
#endif
428
-#ifdef NETDATA_WITH_ZLIB
422
add_to_bi(b, "zlib");
430
-#endif
423
424
#ifdef ENABLE_APPS_PLUGIN
425
add_to_bi(b, "apps");
daemon/main.c
-3
@@ -576,8 +576,6 @@ void web_server_config_options(void)
576
web_allow_mgmt_dns =
577
make_dns_decision(CONFIG_SECTION_WEB, "allow management by dns","heuristic",web_allow_mgmt_from);
578
579
-
580
-#ifdef NETDATA_WITH_ZLIB
579
web_enable_gzip = config_get_boolean(CONFIG_SECTION_WEB, "enable gzip compression", web_enable_gzip);
580
581
char *s = config_get(CONFIG_SECTION_WEB, "gzip compression strategy", "default");
@@ -605,7 +603,6 @@ void web_server_config_options(void)
603
error("Invalid compression level %d. Valid levels are 1 (fastest) to 9 (best ratio). Proceeding with level 9 (best compression).", web_gzip_level);
604
web_gzip_level = 9;
605
}
608
-#endif /* NETDATA_WITH_ZLIB */
606
}
607
608
libnetdata/libnetdata.h
-2
@@ -176,9 +176,7 @@ extern "C" {
176
#include <stdint.h>
177
#endif
178
179
-#ifdef NETDATA_WITH_ZLIB
179
#include <zlib.h>
181
-#endif
180
181
#ifdef HAVE_CAPABILITY
182
#include <sys/capability.h>
web/server/web_client.c
-20
@@ -8,9 +8,7 @@
8
int respect_web_browser_do_not_track_policy = 0;
9
char *web_x_frame_options = NULL;
10
11
-#ifdef NETDATA_WITH_ZLIB
11
int web_enable_gzip = 1, web_gzip_level = 3, web_gzip_strategy = Z_DEFAULT_STRATEGY;
13
-#endif /* NETDATA_WITH_ZLIB */
12
13
inline int web_client_permission_denied(struct web_client *w) {
14
w->response.data->content_type = CT_TEXT_PLAIN;
@@ -142,7 +140,6 @@ static void web_client_reset_allocations(struct web_client *w, bool free_all) {
140
w->auth_bearer_token = NULL;
141
142
// if we had enabled compression, release it
145
-#ifdef NETDATA_WITH_ZLIB
143
if(w->response.zinitialized) {
144
deflateEnd(&w->response.zstream);
145
w->response.zsent = 0;
@@ -154,7 +151,6 @@ static void web_client_reset_allocations(struct web_client *w, bool free_all) {
151
w->response.zinitialized = false;
152
w->flags &= ~WEB_CLIENT_CHUNKED_TRANSFER;
153
}
157
-#endif // NETDATA_WITH_ZLIB
154
}
155
156
void web_client_request_done(struct web_client *w) {
@@ -168,9 +164,7 @@ void web_client_request_done(struct web_client *w) {
164
165
size_t size = (w->mode == WEB_CLIENT_MODE_FILECOPY)?w->response.rlen:w->response.data->len;
166
size_t sent = size;
171
-#ifdef NETDATA_WITH_ZLIB
167
if(likely(w->response.zoutput)) sent = (size_t)w->response.zstream.total_out;
173
-#endif
168
169
// --------------------------------------------------------------------
170
// global statistics
@@ -444,9 +438,6 @@ int mysendfile(struct web_client *w, char *filename) {
438
}
439
#endif
440
447
-
448
-
449
-#ifdef NETDATA_WITH_ZLIB
441
void web_client_enable_deflate(struct web_client *w, int gzip) {
442
if(unlikely(w->response.zinitialized)) {
443
debug(D_DEFLATE, "%llu: Compression has already be initialized for this client.", w->id);
@@ -492,7 +483,6 @@ void web_client_enable_deflate(struct web_client *w, int gzip) {
483
484
debug(D_DEFLATE, "%llu: Initialized compression.", w->id);
485
}
495
-#endif // NETDATA_WITH_ZLIB
486
487
void buffer_data_options2string(BUFFER *wb, uint32_t options) {
488
int count = 0;
@@ -730,16 +720,12 @@ const char *web_response_code_to_string(int code) {
720
static inline char *http_header_parse(struct web_client *w, char *s, int parse_useragent) {
721
static uint32_t hash_origin = 0, hash_connection = 0, hash_donottrack = 0, hash_useragent = 0,
722
hash_authorization = 0, hash_host = 0, hash_forwarded_proto = 0, hash_forwarded_host = 0;
733
-#ifdef NETDATA_WITH_ZLIB
723
static uint32_t hash_accept_encoding = 0;
735
-#endif
724
725
if(unlikely(!hash_origin)) {
726
hash_origin = simple_uhash("Origin");
727
hash_connection = simple_uhash("Connection");
740
-#ifdef NETDATA_WITH_ZLIB
728
hash_accept_encoding = simple_uhash("Accept-Encoding");
742
-#endif
729
hash_donottrack = simple_uhash("DNT");
730
hash_useragent = simple_uhash("User-Agent");
731
hash_authorization = simple_uhash("X-Auth-Token");
@@ -798,7 +784,6 @@ static inline char *http_header_parse(struct web_client *w, char *s, int parse_u
784
strncpyz(buffer, v, ((size_t)(ve - v) < sizeof(buffer) - 1 ? (size_t)(ve - v) : sizeof(buffer) - 1));
785
w->server_host = strdupz(buffer);
786
}
801
-#ifdef NETDATA_WITH_ZLIB
787
else if(hash == hash_accept_encoding && !strcasecmp(s, "Accept-Encoding")) {
788
if(web_enable_gzip) {
789
if(strcasestr(v, "gzip"))
@@ -809,7 +794,6 @@ static inline char *http_header_parse(struct web_client *w, char *s, int parse_u
794
// web_client_enable_deflate(w, 0);
795
}
796
}
812
-#endif /* NETDATA_WITH_ZLIB */
797
#ifdef ENABLE_HTTPS
798
else if(hash == hash_forwarded_proto && !strcasecmp(s, "X-Forwarded-Proto")) {
799
if(strcasestr(v, "https"))
@@ -1736,7 +1720,6 @@ ssize_t web_client_send_chunk_finalize(struct web_client *w)
1720
return bytes;
1721
}
1722
1739
-#ifdef NETDATA_WITH_ZLIB
1723
ssize_t web_client_send_deflate(struct web_client *w)
1724
{
1725
ssize_t len = 0, t = 0;
@@ -1851,12 +1834,9 @@ ssize_t web_client_send_deflate(struct web_client *w)
1834
1835
return(len);
1836
}
1854
-#endif // NETDATA_WITH_ZLIB
1837
1838
ssize_t web_client_send(struct web_client *w) {
1857
-#ifdef NETDATA_WITH_ZLIB
1839
if(likely(w->response.zoutput)) return web_client_send_deflate(w);
1859
-#endif // NETDATA_WITH_ZLIB
1840
1841
ssize_t bytes;
1842
web/server/web_client.h
-4
@@ -5,9 +5,7 @@
5
6
#include "libnetdata/libnetdata.h"
7
8
-#ifdef NETDATA_WITH_ZLIB
8
extern int web_enable_gzip, web_gzip_level, web_gzip_strategy;
10
-#endif /* NETDATA_WITH_ZLIB */
9
10
#define HTTP_REQ_MAX_HEADER_FETCH_TRIES 100
11
@@ -121,13 +119,11 @@ struct response {
119
120
bool zoutput; // if set to 1, web_client_send() will send compressed data
121
124
-#ifdef NETDATA_WITH_ZLIB
122
bool zinitialized;
123
z_stream zstream; // zlib stream for sending compressed output to client
124
size_t zsent; // the compressed bytes we have sent to the client
125
size_t zhave; // the compressed bytes that we have received from zlib
126
Bytef zbuffer[NETDATA_WEB_RESPONSE_ZLIB_CHUNK_SIZE]; // temporary buffer for storing compressed output
130
-#endif /* NETDATA_WITH_ZLIB */
127
};
128
129
struct web_client;