fix the freez pointer of dyncfg (#15719)
Costa Tsaousis committed
Aug 3, 2023 at 09:38 UTC
2fc53f00d40d87f9284e22a4df6014c82374fa0b
3 files changed
+16
-13
libnetdata/dyn_conf/dyn_conf.c
+14
-11
@@ -472,8 +472,11 @@ int register_module(struct configurable_plugin *plugin, struct module *module)
472
return 0;
473
}
474
475
+void freez_dyncfg(void *ptr) {
476
+ freez(ptr);
477
+}
478
476
-void handle_dyncfg_root(struct uni_http_response *resp, int method)
479
+static void handle_dyncfg_root(struct uni_http_response *resp, int method)
480
{
481
if (method != HTTP_METHOD_GET) {
482
resp->content = "method not allowed";
@@ -488,11 +491,11 @@ void handle_dyncfg_root(struct uni_http_response *resp, int method)
491
json_object_put(wrapper);
492
resp->status = HTTP_RESP_OK;
493
resp->content_type = CT_APPLICATION_JSON;
491
- resp->content_free = freez;
494
+ resp->content_free = freez_dyncfg;
495
resp->content_length = strlen(resp->content);
496
}
497
495
-void handle_plugin_root(struct uni_http_response *resp, int method, struct configurable_plugin *plugin, void *post_payload, size_t post_payload_size)
498
+static void handle_plugin_root(struct uni_http_response *resp, int method, struct configurable_plugin *plugin, void *post_payload, size_t post_payload_size)
499
{
500
switch(method) {
501
case HTTP_METHOD_GET:
@@ -501,7 +504,7 @@ void handle_plugin_root(struct uni_http_response *resp, int method, struct confi
504
resp->content = mallocz(cfg.data_size);
505
memcpy(resp->content, cfg.data, cfg.data_size);
506
resp->status = HTTP_RESP_OK;
504
- resp->content_free = free;
507
+ resp->content_free = freez_dyncfg;
508
resp->content_length = cfg.data_size;
509
return;
510
}
@@ -545,7 +548,7 @@ void handle_module_root(struct uni_http_response *resp, int method, struct confi
548
resp->content = mallocz(cfg.data_size);
549
memcpy(resp->content, cfg.data, cfg.data_size);
550
resp->status = HTTP_RESP_OK;
548
- resp->content_free = freez;
551
+ resp->content_free = freez_dyncfg;
552
resp->content_length = cfg.data_size;
553
return;
554
}
@@ -563,7 +566,7 @@ void handle_module_root(struct uni_http_response *resp, int method, struct confi
566
json_object_put(wrapper);
567
resp->status = HTTP_RESP_OK;
568
resp->content_type = CT_APPLICATION_JSON;
566
- resp->content_free = freez;
569
+ resp->content_free = freez_dyncfg;
570
resp->content_length = strlen(resp->content);
571
return;
572
}
@@ -579,7 +582,7 @@ void handle_module_root(struct uni_http_response *resp, int method, struct confi
582
resp->content = mallocz(cfg.data_size);
583
memcpy(resp->content, cfg.data, cfg.data_size);
584
resp->status = HTTP_RESP_OK;
582
- resp->content_free = free;
585
+ resp->content_free = freez_dyncfg;
586
resp->content_length = cfg.data_size;
587
return;
588
} else if (method == HTTP_METHOD_PUT) {
@@ -655,7 +658,7 @@ static inline void _handle_job_root(struct uni_http_response *resp, int method,
658
resp->content = mallocz(cfg.data_size);
659
memcpy(resp->content, cfg.data, cfg.data_size);
660
resp->status = HTTP_RESP_OK;
658
- resp->content_free = freez;
661
+ resp->content_free = freez_dyncfg;
662
resp->content_length = cfg.data_size;
663
return;
664
}
@@ -710,7 +713,7 @@ void handle_job_root(struct uni_http_response *resp, int method, struct module *
713
resp->content = mallocz(cfg.data_size);
714
memcpy(resp->content, cfg.data, cfg.data_size);
715
resp->status = HTTP_RESP_OK;
713
- resp->content_free = freez;
716
+ resp->content_free = freez_dyncfg;
717
resp->content_length = cfg.data_size;
718
return;
719
}
@@ -719,7 +722,7 @@ void handle_job_root(struct uni_http_response *resp, int method, struct module *
722
resp->content = mallocz(cfg.data_size);
723
memcpy(resp->content, cfg.data, cfg.data_size);
724
resp->status = HTTP_RESP_OK;
722
- resp->content_free = freez;
725
+ resp->content_free = freez_dyncfg;
726
resp->content_length = cfg.data_size;
727
return;
728
}
@@ -743,7 +746,7 @@ void handle_job_root(struct uni_http_response *resp, int method, struct module *
746
json_object_put(wrapper);
747
resp->status = HTTP_RESP_OK;
748
resp->content_type = CT_APPLICATION_JSON;
746
- resp->content_free = freez;
749
+ resp->content_free = freez_dyncfg;
750
resp->content_length = strlen(resp->content);
751
return;
752
}
libnetdata/dyn_conf/dyn_conf.h
+1
-1
@@ -130,7 +130,7 @@ struct uni_http_response dyn_conf_process_http_request(int method, const char *p
130
131
// API to be used by main netdata process, initialization and destruction etc.
132
int dyn_conf_init(void);
133
-
133
+void freez_dyncfg(void *ptr);
134
void *dyncfg_main(void *in);
135
136
#endif //DYN_CONF_H
web/api/web_api_v2.c
+1
-1
@@ -698,7 +698,7 @@ static int web_client_api_request_v2_config(RRDHOST *host __maybe_unused, struct
698
if (resp.content_free)
699
resp.content_free(resp.content);
700
resp.content = con;
701
- resp.content_free = freez;
701
+ resp.content_free = freez_dyncfg;
702
}
703
buffer_strcat(w->response.data, resp.content);
704
if (resp.content_free)