Remove h2o header from libnetdata (#16780)
* Limit scope of includes * Remove h2o header from libnetdata
vkalintiris committed
Jan 13, 2024 at 11:26 UTC
3423b5ea83929c20e58ea655413abb6af03ed8e4
7 files changed
+14
-24
libnetdata/buffer/buffer.c
-9
@@ -492,12 +492,3 @@ int buffer_unittest(void) {
492
buffer_free(wb);
493
return errors;
494
}
495
-
496
-#ifdef ENABLE_H2O
497
-h2o_iovec_t buffer_to_h2o_iovec(BUFFER *wb) {
498
- h2o_iovec_t ret;
499
- ret.base = wb->buffer;
500
- ret.len = wb->len;
501
- return ret;
502
-}
503
-#endif
libnetdata/buffer/buffer.h
-8
@@ -6,10 +6,6 @@
6
#include "../string/utf8.h"
7
#include "../libnetdata.h"
8
9
-#ifdef ENABLE_H2O
10
-#include "h2o/memory.h"
11
-#endif
12
-
9
#define BUFFER_JSON_MAX_DEPTH 32 // max is 255
10
11
extern const char hex_digits[16];
@@ -117,10 +113,6 @@ void buffer_char_replace(BUFFER *wb, char from, char to);
113
114
void buffer_print_sn_flags(BUFFER *wb, SN_FLAGS flags, bool send_anomaly_bit);
115
120
-#ifdef ENABLE_H2O
121
-h2o_iovec_t buffer_to_h2o_iovec(BUFFER *wb);
122
-#endif
123
-
116
static inline void buffer_need_bytes(BUFFER *buffer, size_t needed_free_size) {
117
if(unlikely(buffer->len + needed_free_size >= buffer->size))
118
buffer_increase(buffer, needed_free_size + 1);
web/server/h2o/connlist.c
+1
@@ -1,3 +1,4 @@
1
+#include "libnetdata/libnetdata.h"
2
#include "connlist.h"
3
4
conn_list_t conn_list = { NULL, NULL, 0, 0, PTHREAD_MUTEX_INITIALIZER };
web/server/h2o/http_server.c
+11
-5
@@ -1,5 +1,6 @@
1
// SPDX-License-Identifier: GPL-3.0-or-later
2
3
+#include "daemon/common.h"
4
#include "streaming/common.h"
5
#include "http_server.h"
6
@@ -233,14 +234,19 @@ static inline int _netdata_uberhandler(h2o_req_t *req, RRDHOST **host)
234
web_client_api_request_v1(*host, &w, path_unescaped);
235
freez(path_unescaped);
236
236
- h2o_iovec_t body = buffer_to_h2o_iovec(w.response.data);
237
-
237
// we move msg body to req->pool managed memory as it has to
238
// live until whole response has been encrypted and sent
239
// when req is finished memory will be freed with the pool
241
- void *managed = h2o_mem_alloc_shared(&req->pool, body.len, NULL);
242
- memcpy(managed, body.base, body.len);
243
- body.base = managed;
240
+ h2o_iovec_t body;
241
+ {
242
+ BUFFER *wb = w.response.data;
243
+ body.base = wb->buffer;
244
+ body.len = wb->len;
245
+
246
+ void *managed = h2o_mem_alloc_shared(&req->pool, body.len, NULL);
247
+ memcpy(managed, body.base, body.len);
248
+ body.base = managed;
249
+ }
250
251
req->res.status = HTTP_RESP_OK;
252
req->res.reason = "OK";
web/server/h2o/http_server.h
+1
-1
@@ -3,7 +3,7 @@
3
#ifndef HTTP_SERVER_H
4
#define HTTP_SERVER_H
5
6
-#include "libnetdata/libnetdata.h"
6
+#include <stddef.h>
7
8
void *h2o_main(void * ptr);
9
web/server/h2o/streaming.c
+1
@@ -1,5 +1,6 @@
1
// SPDX-License-Identifier: GPL-3.0-or-later
2
3
+#include "daemon/common.h"
4
#include "streaming.h"
5
#include "connlist.h"
6
#include "h2o_utils.h"
web/server/h2o/streaming.h
-1
@@ -3,7 +3,6 @@
3
#ifndef HTTPD_STREAMING_H
4
#define HTTPD_STREAMING_H
5
6
-#include "daemon/common.h"
6
#include "mqtt_websockets/c-rbuf/include/ringbuffer.h"
7
#include "h2o.h"
8