code cleanup (#16542)
fixed minor code cleanup warnings
Costa Tsaousis committed
Dec 12, 2023 at 18:12 UTC
dc7ca8644fcca2cc7d2a165dd614d7f00bd8eb7e
73 files changed
+369
-450
aclk/aclk_proxy.c
-14
@@ -15,20 +15,6 @@ struct {
15
{ .type = PROXY_TYPE_UNKNOWN, .url_str = NULL },
16
};
17
18
-const char *aclk_proxy_type_to_s(ACLK_PROXY_TYPE *type)
19
-{
20
- switch (*type) {
21
- case PROXY_DISABLED:
22
- return "disabled";
23
- case PROXY_TYPE_HTTP:
24
- return "HTTP";
25
- case PROXY_TYPE_SOCKS5:
26
- return "SOCKS";
27
- default:
28
- return "Unknown";
29
- }
30
-}
31
-
18
static inline ACLK_PROXY_TYPE aclk_find_proxy(const char *string)
19
{
20
int i = 0;
aclk/aclk_proxy.h
-1
@@ -13,7 +13,6 @@ typedef enum aclk_proxy_type {
13
PROXY_NOT_SET,
14
} ACLK_PROXY_TYPE;
15
16
-const char *aclk_proxy_type_to_s(ACLK_PROXY_TYPE *type);
16
ACLK_PROXY_TYPE aclk_verify_proxy(const char *string);
17
const char *aclk_lws_wss_get_proxy_setting(ACLK_PROXY_TYPE *type);
18
void safe_log_proxy_censor(char *proxy);
aclk/aclk_query_queue.c
+1
-1
@@ -92,7 +92,7 @@ void aclk_queue_flush(void)
92
while (query) {
93
aclk_query_free(query);
94
query = aclk_queue_pop();
95
- };
95
+ }
96
}
97
98
aclk_query_t aclk_query_new(aclk_query_type_t type)
aclk/aclk_query_queue.h
+4
-3
@@ -75,12 +75,13 @@ void aclk_queue_flush(void);
75
void aclk_queue_lock(void);
76
void aclk_queue_unlock(void);
77
78
-#define QUEUE_IF_PAYLOAD_PRESENT(query) \
78
+#define QUEUE_IF_PAYLOAD_PRESENT(query) do { \
79
if (likely(query->data.bin_payload.payload)) { \
80
aclk_queue_query(query); \
81
} else { \
82
- netdata_log_error("Failed to generate payload (%s)", __FUNCTION__); \
82
+ nd_log(NDLS_DAEMON, NDLP_ERR, "Failed to generate payload"); \
83
aclk_query_free(query); \
84
- }
84
+ } \
85
+} while(0)
86
87
#endif /* NETDATA_ACLK_QUERY_QUEUE_H */
aclk/https_client.c
+3
-15
@@ -8,8 +8,6 @@
8
9
#include "daemon/global_statistics.h"
10
11
-#define DEFAULT_CHUNKED_RESPONSE_BUFFER_SIZE (4096)
12
-
11
static const char *http_req_type_to_str(http_req_type_t req) {
12
switch (req) {
13
case HTTP_REQ_GET:
@@ -25,7 +23,6 @@ static const char *http_req_type_to_str(http_req_type_t req) {
23
24
#define TRANSFER_ENCODING_CHUNKED (-2)
25
28
-#define HTTP_PARSE_CTX_INITIALIZER { .state = HTTP_PARSE_INITIAL, .content_length = -1, .http_code = 0 }
26
void http_parse_ctx_create(http_parse_ctx *ctx)
27
{
28
ctx->state = HTTP_PARSE_INITIAL;
@@ -316,8 +313,6 @@ typedef struct https_req_ctx {
313
314
size_t written;
315
319
- int self_signed_allowed;
320
-
316
http_parse_ctx parse_ctx;
317
318
time_t req_start_time;
@@ -762,12 +757,6 @@ void https_req_response_free(https_req_response_t *res) {
757
freez(res->payload);
758
}
759
765
-void https_req_response_init(https_req_response_t *res) {
766
- res->http_code = 0;
767
- res->payload = NULL;
768
- res->payload_size = 0;
769
-}
770
-
760
static inline char *UNUSED_FUNCTION(min_non_null)(char *a, char *b) {
761
if (!a)
762
return b;
@@ -816,12 +805,11 @@ static inline void port_by_proto(url_t *url) {
805
}
806
}
807
819
-#define STRDUPZ_2PTR(dest, start, end) \
820
- { \
808
+#define STRDUPZ_2PTR(dest, start, end) do { \
809
dest = mallocz(1 + end - start); \
810
memcpy(dest, start, end - start); \
811
dest[end - start] = 0; \
824
- }
812
+ } while(0)
813
814
int url_parse(const char *url, url_t *parsed) {
815
const char *start = url;
@@ -833,7 +821,7 @@ int url_parse(const char *url, url_t *parsed) {
821
return 1;
822
}
823
836
- STRDUPZ_2PTR(parsed->proto, start, end)
824
+ STRDUPZ_2PTR(parsed->proto, start, end);
825
start = end + strlen(URI_PROTO_SEPARATOR);
826
}
827
aclk/https_client.h
-1
@@ -56,7 +56,6 @@ int url_parse(const char *url, url_t *parsed);
56
void url_t_destroy(url_t *url);
57
58
void https_req_response_free(https_req_response_t *res);
59
-void https_req_response_init(https_req_response_t *res);
59
60
#define HTTPS_REQ_RESPONSE_T_INITIALIZER \
61
{ \
aclk/schema-wrappers/schema_wrapper_utils.h
+4
-4
@@ -10,11 +10,11 @@
10
#include <google/protobuf/map.h>
11
12
#if GOOGLE_PROTOBUF_VERSION < 3001000
13
-#define PROTO_COMPAT_MSG_SIZE(msg) (size_t)msg.ByteSize();
14
-#define PROTO_COMPAT_MSG_SIZE_PTR(msg) (size_t)msg->ByteSize();
13
+#define PROTO_COMPAT_MSG_SIZE(msg) (size_t)msg.ByteSize()
14
+#define PROTO_COMPAT_MSG_SIZE_PTR(msg) (size_t)msg->ByteSize()
15
#else
16
-#define PROTO_COMPAT_MSG_SIZE(msg) msg.ByteSizeLong();
17
-#define PROTO_COMPAT_MSG_SIZE_PTR(msg) msg->ByteSizeLong();
16
+#define PROTO_COMPAT_MSG_SIZE(msg) msg.ByteSizeLong()
17
+#define PROTO_COMPAT_MSG_SIZE_PTR(msg) msg->ByteSizeLong()
18
#endif
19
20
void set_google_timestamp_from_timeval(struct timeval tv, google::protobuf::Timestamp *ts);
claim/claim.c
+1
-7
@@ -44,8 +44,6 @@ char *get_agent_claimid()
44
#define CLAIMING_COMMAND_LENGTH 16384
45
#define CLAIMING_PROXY_LENGTH (CLAIMING_COMMAND_LENGTH/4)
46
47
-extern struct registry registry;
48
-
47
/* rrd_init() and post_conf_load() must have been called before this function */
48
CLAIM_AGENT_RESPONSE claim_agent(const char *claiming_arguments, bool force, const char **msg __maybe_unused)
49
{
@@ -102,7 +100,7 @@ CLAIM_AGENT_RESPONSE claim_agent(const char *claiming_arguments, bool force, con
100
101
netdata_log_info("Waiting for claiming command '%s' to finish.", command_exec_buffer);
102
char read_buffer[100 + 1];
105
- while (fgets(read_buffer, 100, fp_child_output) != NULL) {;}
103
+ while (fgets(read_buffer, 100, fp_child_output) != NULL) ;
104
105
exit_code = netdata_pclose(fp_child_input, fp_child_output, command_pid);
106
@@ -138,10 +136,6 @@ CLAIM_AGENT_RESPONSE claim_agent(const char *claiming_arguments, bool force, con
136
return CLAIM_AGENT_FAILED_WITH_MESSAGE;
137
}
138
141
-#ifdef ENABLE_ACLK
142
-extern int aclk_connected, aclk_kill_link, aclk_disable_runtime;
143
-#endif
144
-
139
/* Change the claimed state of the agent.
140
*
141
* This only happens when the user has explicitly requested it:
cli/cli.c
+2
-2
@@ -17,7 +17,7 @@ uint64_t debug_flags;
17
void netdata_logger_fatal( const char *file __maybe_unused, const char *function __maybe_unused, const unsigned long line __maybe_unused, const char *fmt __maybe_unused, ... )
18
{
19
abort();
20
-};
20
+}
21
#endif
22
23
#ifdef NETDATA_TRACE_ALLOCATIONS
@@ -129,7 +129,7 @@ static void parse_command_reply(BUFFER *buf)
129
pos < response_string + response_string_size && !syntax_error ;
130
++pos) {
131
/* Skip white-space characters */
132
- for ( ; isspace(*pos) && ('\0' != *pos); ++pos) {;}
132
+ for ( ; isspace(*pos) && ('\0' != *pos); ++pos) ;
133
134
if ('\0' == *pos)
135
continue;
collectors/apps.plugin/apps_plugin.c
+3
-3
@@ -704,7 +704,7 @@ int read_user_or_group_ids(struct user_or_group_ids *ids, struct timespec *last_
704
else {
705
if(unlikely(avl_insert(&ids->index, (avl_t *) user_or_group_id) != (void *) user_or_group_id)) {
706
netdata_log_error("INTERNAL ERROR: duplicate indexing of id during realloc");
707
- };
707
+ }
708
709
user_or_group_id->next = ids->root;
710
ids->root = user_or_group_id;
@@ -1239,11 +1239,11 @@ cleanup:
1239
// each parameter is accessed only ONCE - so it is safe to pass function calls
1240
// or other macros as parameters
1241
1242
-#define incremental_rate(rate_variable, last_kernel_variable, new_kernel_value, collected_usec, last_collected_usec) { \
1242
+#define incremental_rate(rate_variable, last_kernel_variable, new_kernel_value, collected_usec, last_collected_usec) do { \
1243
kernel_uint_t _new_tmp = new_kernel_value; \
1244
(rate_variable) = (_new_tmp - (last_kernel_variable)) * (USEC_PER_SEC * RATES_DETAIL) / ((collected_usec) - (last_collected_usec)); \
1245
(last_kernel_variable) = _new_tmp; \
1246
- }
1246
+ } while(0)
1247
1248
// the same macro for struct pid members
1249
#define pid_incremental_rate(type, var, value) \
collectors/cups.plugin/cups_plugin.c
+1
-1
@@ -175,7 +175,7 @@ struct job_metrics *get_job_metrics(char *dest) {
175
struct job_metrics new_job_metrics = { .id = ++job_id };
176
jm = dictionary_set(dict_dest_job_metrics, dest, &new_job_metrics, sizeof(struct job_metrics));
177
send_job_charts_definitions_to_netdata(dest, jm->id, false);
178
- };
178
+ }
179
180
return jm;
181
}
collectors/diskspace.plugin/plugin_diskspace.c
+2
-2
@@ -148,7 +148,7 @@ static void add_basic_mountinfo(struct basic_mountinfo **root, struct mountinfo
148
149
bmi->next = *root;
150
*root = bmi;
151
-};
151
+}
152
153
static void free_basic_mountinfo(struct basic_mountinfo *bmi)
154
{
@@ -160,7 +160,7 @@ static void free_basic_mountinfo(struct basic_mountinfo *bmi)
160
161
freez(bmi);
162
}
163
-};
163
+}
164
165
static void free_basic_mountinfo_list(struct basic_mountinfo *root)
166
{
collectors/ebpf.plugin/ebpf_cachestat.c
+2
-2
@@ -559,8 +559,8 @@ static void ebpf_cachestat_exit(void *ptr)
559
ebpf_obsolete_cachestat_global(em);
560
561
#ifdef NETDATA_DEV_MODE
562
- if (ebpf_aral_cachestat_pid)
563
- ebpf_statistic_obsolete_aral_chart(em, cachestat_disable_priority);
562
+ if (ebpf_aral_cachestat_pid)
563
+ ebpf_statistic_obsolete_aral_chart(em, cachestat_disable_priority);
564
#endif
565
566
collectors/ebpf.plugin/ebpf_fd.c
+2
-2
@@ -580,8 +580,8 @@ static void ebpf_fd_exit(void *ptr)
580
ebpf_obsolete_fd_global(em);
581
582
#ifdef NETDATA_DEV_MODE
583
- if (ebpf_aral_fd_pid)
584
- ebpf_statistic_obsolete_aral_chart(em, fd_disable_priority);
583
+ if (ebpf_aral_fd_pid)
584
+ ebpf_statistic_obsolete_aral_chart(em, fd_disable_priority);
585
#endif
586
587
collectors/ebpf.plugin/ebpf_filesystem.c
+1
-1
@@ -321,7 +321,7 @@ static inline int ebpf_fs_load_and_attach(ebpf_local_maps_t *map, struct filesys
321
ret = ebpf_fs_attach_kprobe(obj, functions);
322
323
if (!ret)
324
- map->map_fd = bpf_map__fd(obj->maps.tbl_fs);;
324
+ map->map_fd = bpf_map__fd(obj->maps.tbl_fs);
325
326
return ret;
327
}
collectors/ebpf.plugin/ebpf_process.c
+2
-2
@@ -786,8 +786,8 @@ static void ebpf_process_exit(void *ptr)
786
ebpf_obsolete_process_global(em);
787
788
#ifdef NETDATA_DEV_MODE
789
- if (ebpf_aral_process_stat)
790
- ebpf_statistic_obsolete_aral_chart(em, process_disable_priority);
789
+ if (ebpf_aral_process_stat)
790
+ ebpf_statistic_obsolete_aral_chart(em, process_disable_priority);
791
#endif
792
793
fflush(stdout);
collectors/ebpf.plugin/ebpf_shm.c
+2
-2
@@ -479,8 +479,8 @@ static void ebpf_shm_exit(void *ptr)
479
ebpf_obsolete_shm_global(em);
480
481
#ifdef NETDATA_DEV_MODE
482
- if (ebpf_aral_shm_pid)
483
- ebpf_statistic_obsolete_aral_chart(em, shm_disable_priority);
482
+ if (ebpf_aral_shm_pid)
483
+ ebpf_statistic_obsolete_aral_chart(em, shm_disable_priority);
484
#endif
485
486
fflush(stdout);
collectors/idlejitter.plugin/plugin_idlejitter.c
+1
-3
@@ -68,9 +68,7 @@ void *cpuidlejitter_main(void *ptr) {
68
usec_t error = dt - sleep_ut;
69
error_total += error;
70
71
- if(unlikely(!iterations))
72
- error_min = error;
73
- else if(error < error_min)
71
+ if(unlikely(!iterations || error < error_min))
72
error_min = error;
73
74
if(error > error_max)
collectors/perf.plugin/perf_plugin.c
+2
-2
@@ -35,8 +35,8 @@
35
#define RRD_FAMILY_SW "software"
36
#define RRD_FAMILY_CACHE "cache"
37
38
-#define NO_FD -1
39
-#define ALL_PIDS -1
38
+#define NO_FD (-1)
39
+#define ALL_PIDS (-1)
40
#define RUNNING_THRESHOLD 100
41
42
static int debug = 0;
collectors/plugins.d/plugins_d.c
+46
-48
@@ -140,67 +140,65 @@ static void pluginsd_worker_thread_handle_error(struct plugind *cd, int worker_r
140
static void *pluginsd_worker_thread(void *arg) {
141
worker_register("PLUGINSD");
142
143
- netdata_thread_cleanup_push(pluginsd_worker_thread_cleanup, arg);
143
+ netdata_thread_cleanup_push(pluginsd_worker_thread_cleanup, arg)
144
+ {
145
+ struct plugind *cd = (struct plugind *) arg;
146
+ plugin_set_running(cd);
147
145
- {
146
- struct plugind *cd = (struct plugind *) arg;
147
- plugin_set_running(cd);
148
+ size_t count = 0;
149
149
- size_t count = 0;
150
+ while(service_running(SERVICE_COLLECTORS)) {
151
+ FILE *fp_child_input = NULL;
152
+ FILE *fp_child_output = netdata_popen(cd->cmd, &cd->unsafe.pid, &fp_child_input);
153
151
- while(service_running(SERVICE_COLLECTORS)) {
152
- FILE *fp_child_input = NULL;
153
- FILE *fp_child_output = netdata_popen(cd->cmd, &cd->unsafe.pid, &fp_child_input);
154
-
155
- if(unlikely(!fp_child_input || !fp_child_output)) {
156
- netdata_log_error("PLUGINSD: 'host:%s', cannot popen(\"%s\", \"r\").",
157
- rrdhost_hostname(cd->host), cd->cmd);
158
- break;
159
- }
160
-
161
- nd_log(NDLS_DAEMON, NDLP_DEBUG,
162
- "PLUGINSD: 'host:%s' connected to '%s' running on pid %d",
163
- rrdhost_hostname(cd->host),
164
- cd->fullfilename, cd->unsafe.pid);
154
+ if(unlikely(!fp_child_input || !fp_child_output)) {
155
+ netdata_log_error("PLUGINSD: 'host:%s', cannot popen(\"%s\", \"r\").",
156
+ rrdhost_hostname(cd->host), cd->cmd);
157
+ break;
158
+ }
159
166
- const char *plugin = strrchr(cd->fullfilename, '/');
167
- if(plugin)
168
- plugin++;
169
- else
170
- plugin = cd->fullfilename;
160
+ nd_log(NDLS_DAEMON, NDLP_DEBUG,
161
+ "PLUGINSD: 'host:%s' connected to '%s' running on pid %d",
162
+ rrdhost_hostname(cd->host),
163
+ cd->fullfilename, cd->unsafe.pid);
164
172
- char module[100];
173
- snprintfz(module, sizeof(module), "plugins.d[%s]", plugin);
174
- ND_LOG_STACK lgs[] = {
175
- ND_LOG_FIELD_TXT(NDF_MODULE, module),
176
- ND_LOG_FIELD_TXT(NDF_NIDL_NODE, rrdhost_hostname(cd->host)),
177
- ND_LOG_FIELD_TXT(NDF_SRC_TRANSPORT, "pluginsd"),
178
- ND_LOG_FIELD_END(),
179
- };
180
- ND_LOG_STACK_PUSH(lgs);
165
+ const char *plugin = strrchr(cd->fullfilename, '/');
166
+ if(plugin)
167
+ plugin++;
168
+ else
169
+ plugin = cd->fullfilename;
170
182
- count = pluginsd_process(cd->host, cd, fp_child_input, fp_child_output, 0);
171
+ char module[100];
172
+ snprintfz(module, sizeof(module), "plugins.d[%s]", plugin);
173
+ ND_LOG_STACK lgs[] = {
174
+ ND_LOG_FIELD_TXT(NDF_MODULE, module),
175
+ ND_LOG_FIELD_TXT(NDF_NIDL_NODE, rrdhost_hostname(cd->host)),
176
+ ND_LOG_FIELD_TXT(NDF_SRC_TRANSPORT, "pluginsd"),
177
+ ND_LOG_FIELD_END(),
178
+ };
179
+ ND_LOG_STACK_PUSH(lgs);
180
184
- nd_log(NDLS_DAEMON, NDLP_DEBUG,
185
- "PLUGINSD: 'host:%s', '%s' (pid %d) disconnected after %zu successful data collections (ENDs).",
186
- rrdhost_hostname(cd->host), cd->fullfilename, cd->unsafe.pid, count);
181
+ count = pluginsd_process(cd->host, cd, fp_child_input, fp_child_output, 0);
182
188
- killpid(cd->unsafe.pid);
183
+ nd_log(NDLS_DAEMON, NDLP_DEBUG,
184
+ "PLUGINSD: 'host:%s', '%s' (pid %d) disconnected after %zu successful data collections (ENDs).",
185
+ rrdhost_hostname(cd->host), cd->fullfilename, cd->unsafe.pid, count);
186
190
- int worker_ret_code = netdata_pclose(fp_child_input, fp_child_output, cd->unsafe.pid);
187
+ killpid(cd->unsafe.pid);
188
192
- if(likely(worker_ret_code == 0))
193
- pluginsd_worker_thread_handle_success(cd);
194
- else
195
- pluginsd_worker_thread_handle_error(cd, worker_ret_code);
189
+ int worker_ret_code = netdata_pclose(fp_child_input, fp_child_output, cd->unsafe.pid);
190
197
- cd->unsafe.pid = 0;
191
+ if(likely(worker_ret_code == 0))
192
+ pluginsd_worker_thread_handle_success(cd);
193
+ else
194
+ pluginsd_worker_thread_handle_error(cd, worker_ret_code);
195
199
- if(unlikely(!plugin_is_enabled(cd)))
200
- break;
201
- }
202
- }
196
+ cd->unsafe.pid = 0;
197
198
+ if(unlikely(!plugin_is_enabled(cd)))
199
+ break;
200
+ }
201
+ }
202
netdata_thread_cleanup_pop(1);
203
return NULL;
204
}
collectors/plugins.d/pluginsd_parser.c
+42
-45
@@ -2945,56 +2945,53 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp_plugi
2945
2946
// this keeps the parser with its current value
2947
// so, parser needs to be allocated before pushing it
2948
- netdata_thread_cleanup_push(pluginsd_process_thread_cleanup, parser);
2949
-
2950
- {
2951
- ND_LOG_STACK lgs[] = {
2952
- ND_LOG_FIELD_CB(NDF_REQUEST, line_splitter_reconstruct_line, &parser->line),
2953
- ND_LOG_FIELD_CB(NDF_NIDL_NODE, parser_reconstruct_node, parser),
2954
- ND_LOG_FIELD_CB(NDF_NIDL_INSTANCE, parser_reconstruct_instance, parser),
2955
- ND_LOG_FIELD_CB(NDF_NIDL_CONTEXT, parser_reconstruct_context, parser),
2956
- ND_LOG_FIELD_END(),
2957
- };
2958
- ND_LOG_STACK_PUSH(lgs);
2959
-
2960
- buffered_reader_init(&parser->reader);
2961
- BUFFER *buffer = buffer_create(sizeof(parser->reader.read_buffer) + 2, NULL);
2962
- while(likely(service_running(SERVICE_COLLECTORS))) {
2963
-
2964
- if(unlikely(!buffered_reader_next_line(&parser->reader, buffer))) {
2965
- buffered_reader_ret_t ret = buffered_reader_read_timeout(
2966
- &parser->reader,
2967
- fileno((FILE *) parser->fp_input),
2968
- 2 * 60 * MSEC_PER_SEC, true
2969
- );
2970
-
2971
- if(unlikely(ret != BUFFERED_READER_READ_OK))
2972
- break;
2973
-
2974
- continue;
2975
- }
2976
-
2977
- if(unlikely(parser_action(parser, buffer->buffer)))
2978
- break;
2948
+ netdata_thread_cleanup_push(pluginsd_process_thread_cleanup, parser)
2949
+ {
2950
+ ND_LOG_STACK lgs[] = {
2951
+ ND_LOG_FIELD_CB(NDF_REQUEST, line_splitter_reconstruct_line, &parser->line),
2952
+ ND_LOG_FIELD_CB(NDF_NIDL_NODE, parser_reconstruct_node, parser),
2953
+ ND_LOG_FIELD_CB(NDF_NIDL_INSTANCE, parser_reconstruct_instance, parser),
2954
+ ND_LOG_FIELD_CB(NDF_NIDL_CONTEXT, parser_reconstruct_context, parser),
2955
+ ND_LOG_FIELD_END(),
2956
+ };
2957
+ ND_LOG_STACK_PUSH(lgs);
2958
2980
- buffer->len = 0;
2981
- buffer->buffer[0] = '\0';
2982
- }
2983
- buffer_free(buffer);
2959
+ buffered_reader_init(&parser->reader);
2960
+ BUFFER *buffer = buffer_create(sizeof(parser->reader.read_buffer) + 2, NULL);
2961
+ while(likely(service_running(SERVICE_COLLECTORS))) {
2962
2985
- cd->unsafe.enabled = parser->user.enabled;
2986
- count = parser->user.data_collections_count;
2963
+ if(unlikely(!buffered_reader_next_line(&parser->reader, buffer))) {
2964
+ buffered_reader_ret_t ret = buffered_reader_read_timeout(
2965
+ &parser->reader,
2966
+ fileno((FILE *) parser->fp_input),
2967
+ 2 * 60 * MSEC_PER_SEC, true
2968
+ );
2969
2988
- if(likely(count)) {
2989
- cd->successful_collections += count;
2990
- cd->serial_failures = 0;
2991
- }
2992
- else
2993
- cd->serial_failures++;
2970
+ if(unlikely(ret != BUFFERED_READER_READ_OK))
2971
+ break;
2972
+
2973
+ continue;
2974
}
2975
2996
- // free parser with the pop function
2997
- netdata_thread_cleanup_pop(1);
2976
+ if(unlikely(parser_action(parser, buffer->buffer)))
2977
+ break;
2978
+
2979
+ buffer->len = 0;
2980
+ buffer->buffer[0] = '\0';
2981
+ }
2982
+ buffer_free(buffer);
2983
+
2984
+ cd->unsafe.enabled = parser->user.enabled;
2985
+ count = parser->user.data_collections_count;
2986
+
2987
+ if(likely(count)) {
2988
+ cd->successful_collections += count;
2989
+ cd->serial_failures = 0;
2990
+ }
2991
+ else
2992
+ cd->serial_failures++;
2993
+ }
2994
+ netdata_thread_cleanup_pop(1); // free parser with the pop function
2995
2996
return count;
2997
}
collectors/proc.plugin/plugin_proc.c
+42
-44
@@ -157,59 +157,57 @@ void *proc_main(void *ptr)
157
netdev_thread, THREAD_NETDEV_NAME, NETDATA_THREAD_OPTION_JOINABLE, netdev_main, netdev_thread);
158
}
159
160
- netdata_thread_cleanup_push(proc_main_cleanup, ptr);
160
+ netdata_thread_cleanup_push(proc_main_cleanup, ptr)
161
+ {
162
+ config_get_boolean("plugin:proc", "/proc/pagetypeinfo", CONFIG_BOOLEAN_NO);
163
162
- {
163
- config_get_boolean("plugin:proc", "/proc/pagetypeinfo", CONFIG_BOOLEAN_NO);
164
+ // check the enabled status for each module
165
+ int i;
166
+ for(i = 0; proc_modules[i].name; i++) {
167
+ struct proc_module *pm = &proc_modules[i];
168
165
- // check the enabled status for each module
166
- int i;
167
- for(i = 0; proc_modules[i].name; i++) {
168
- struct proc_module *pm = &proc_modules[i];
169
+ pm->enabled = config_get_boolean("plugin:proc", pm->name, CONFIG_BOOLEAN_YES);
170
+ pm->rd = NULL;
171
170
- pm->enabled = config_get_boolean("plugin:proc", pm->name, CONFIG_BOOLEAN_YES);
171
- pm->rd = NULL;
172
-
173
- worker_register_job_name(i, proc_modules[i].dim);
174
- }
172
+ worker_register_job_name(i, proc_modules[i].dim);
173
+ }
174
176
- usec_t step = localhost->rrd_update_every * USEC_PER_SEC;
177
- heartbeat_t hb;
178
- heartbeat_init(&hb);
175
+ usec_t step = localhost->rrd_update_every * USEC_PER_SEC;
176
+ heartbeat_t hb;
177
+ heartbeat_init(&hb);
178
180
- inside_lxc_container = is_lxcfs_proc_mounted();
179
+ inside_lxc_container = is_lxcfs_proc_mounted();
180
181
#define LGS_MODULE_ID 0
182
184
- ND_LOG_STACK lgs[] = {
185
- [LGS_MODULE_ID] = ND_LOG_FIELD_TXT(NDF_MODULE, "proc.plugin"),
186
- ND_LOG_FIELD_END(),
187
- };
188
- ND_LOG_STACK_PUSH(lgs);
189
-
190
- while(service_running(SERVICE_COLLECTORS)) {
191
- worker_is_idle();
192
- usec_t hb_dt = heartbeat_next(&hb, step);
193
-
194
- if(unlikely(!service_running(SERVICE_COLLECTORS)))
195
- break;
196
-
197
- for(i = 0; proc_modules[i].name; i++) {
198
- if(unlikely(!service_running(SERVICE_COLLECTORS)))
199
- break;
200
-
201
- struct proc_module *pm = &proc_modules[i];
202
- if(unlikely(!pm->enabled))
203
- continue;
204
-
205
- worker_is_busy(i);
206
- lgs[LGS_MODULE_ID] = ND_LOG_FIELD_CB(NDF_MODULE, log_proc_module, pm);
207
- pm->enabled = !pm->func(localhost->rrd_update_every, hb_dt);
208
- lgs[LGS_MODULE_ID] = ND_LOG_FIELD_TXT(NDF_MODULE, "proc.plugin");
209
- }
210
- }
211
- }
183
+ ND_LOG_STACK lgs[] = {
184
+ [LGS_MODULE_ID] = ND_LOG_FIELD_TXT(NDF_MODULE, "proc.plugin"),
185
+ ND_LOG_FIELD_END(),
186
+ };
187
+ ND_LOG_STACK_PUSH(lgs);
188
+
189
+ while(service_running(SERVICE_COLLECTORS)) {
190
+ worker_is_idle();
191
+ usec_t hb_dt = heartbeat_next(&hb, step);
192
+
193
+ if(unlikely(!service_running(SERVICE_COLLECTORS)))
194
+ break;
195
196
+ for(i = 0; proc_modules[i].name; i++) {
197
+ if(unlikely(!service_running(SERVICE_COLLECTORS)))
198
+ break;
199
+
200
+ struct proc_module *pm = &proc_modules[i];
201
+ if(unlikely(!pm->enabled))
202
+ continue;
203
+
204
+ worker_is_busy(i);
205
+ lgs[LGS_MODULE_ID] = ND_LOG_FIELD_CB(NDF_MODULE, log_proc_module, pm);
206
+ pm->enabled = !pm->func(localhost->rrd_update_every, hb_dt);
207
+ lgs[LGS_MODULE_ID] = ND_LOG_FIELD_TXT(NDF_MODULE, "proc.plugin");
208
+ }
209
+ }
210
+ }
211
netdata_thread_cleanup_pop(1);
212
return NULL;
213
}
collectors/proc.plugin/proc_net_dev.c
+19
-19
@@ -1924,32 +1924,32 @@ void *netdev_main(void *ptr)
1924
worker_register("NETDEV");
1925
worker_register_job_name(0, "netdev");
1926
1927
- netdata_thread_cleanup_push(netdev_main_cleanup, ptr);
1927
+ netdata_thread_cleanup_push(netdev_main_cleanup, ptr) {
1928
+ rrd_collector_started();
1929
+ rrd_function_add(localhost, NULL, "network-interfaces", 10, RRDFUNCTIONS_NETDEV_HELP, true
1930
+ , netdev_function_net_interfaces, NULL);
1931
1929
- rrd_collector_started();
1930
- rrd_function_add(localhost, NULL, "network-interfaces", 10, RRDFUNCTIONS_NETDEV_HELP, true, netdev_function_net_interfaces, NULL);
1932
+ usec_t step = localhost->rrd_update_every * USEC_PER_SEC;
1933
+ heartbeat_t hb;
1934
+ heartbeat_init(&hb);
1935
1932
- usec_t step = localhost->rrd_update_every * USEC_PER_SEC;
1933
- heartbeat_t hb;
1934
- heartbeat_init(&hb);
1936
+ while (service_running(SERVICE_COLLECTORS)) {
1937
+ worker_is_idle();
1938
+ usec_t hb_dt = heartbeat_next(&hb, step);
1939
1936
- while (service_running(SERVICE_COLLECTORS)) {
1937
- worker_is_idle();
1938
- usec_t hb_dt = heartbeat_next(&hb, step);
1940
+ if (unlikely(!service_running(SERVICE_COLLECTORS)))
1941
+ break;
1942
1940
- if (unlikely(!service_running(SERVICE_COLLECTORS)))
1941
- break;
1942
-
1943
- cgroup_netdev_reset_all();
1943
+ cgroup_netdev_reset_all();
1944
1945
- worker_is_busy(0);
1945
+ worker_is_busy(0);
1946
1947
- netdata_mutex_lock(&netdev_dev_mutex);
1948
- if(do_proc_net_dev(localhost->rrd_update_every, hb_dt))
1949
- break;
1950
- netdata_mutex_unlock(&netdev_dev_mutex);
1947
+ netdata_mutex_lock(&netdev_dev_mutex);
1948
+ if (do_proc_net_dev(localhost->rrd_update_every, hb_dt))
1949
+ break;
1950
+ netdata_mutex_unlock(&netdev_dev_mutex);
1951
+ }
1952
}
1952
-
1953
netdata_thread_cleanup_pop(1);
1954
1955
return NULL;
collectors/proc.plugin/proc_spl_kstat_zfs.c
+1
-1
@@ -357,7 +357,7 @@ int do_proc_spl_kstat_zfs_pool_state(int update_every, usec_t dt)
357
if (unlikely(!pool)) {
358
struct zfs_pool new_zfs_pool = {};
359
pool = dictionary_set(zfs_pools, de->d_name, &new_zfs_pool, sizeof(struct zfs_pool));
360
- };
360
+ }
361
362
pool->updated = 1;
363
collectors/proc.plugin/sys_class_drm.c
+2
-2
@@ -885,14 +885,14 @@ int do_sys_class_drm(int update_every, usec_t dt) {
885
886
887
collected_number tmp_val;
888
- #define set_prop_pathname(prop_filename, prop_pathname, p_ff){ \
888
+ #define set_prop_pathname(prop_filename, prop_pathname, p_ff) do { \
889
snprintfz(filename, FILENAME_MAX, "%s/%s", c->pathname, prop_filename); \
890
if((p_ff && !read_clk_freq_file(p_ff, filename, &tmp_val)) || \
891
!read_single_number_file(filename, (unsigned long long *) &tmp_val)) \
892
prop_pathname = strdupz(filename); \
893
else \
894
collector_info("Cannot read file '%s'", filename); \
895
- }
895
+ } while(0)
896
897
/* Initialize GPU and VRAM utilization metrics */
898
collectors/proc.plugin/sys_kernel_mm_ksm.c
+1
-1
@@ -13,7 +13,7 @@ typedef struct ksm_name_value {
13
#define PAGES_SHARING 1
14
#define PAGES_UNSHARED 2
15
#define PAGES_VOLATILE 3
16
-#define PAGES_TO_SCAN 4
16
+// #define PAGES_TO_SCAN 4
17
18
KSM_NAME_VALUE values[] = {
19
[PAGES_SHARED] = { "/sys/kernel/mm/ksm/pages_shared", 0ULL },
collectors/profile.plugin/plugin_profile.cc
-2
@@ -14,8 +14,6 @@ extern "C" {
14
#include <thread>
15
#include <vector>
16
17
-#define PLUGIN_PROFILE_NAME "profile.plugin"
18
-
17
#define CONFIG_SECTION_PROFILE "plugin:profile"
18
19
class Generator {
collectors/slabinfo.plugin/slabinfo.c
+7
-4
@@ -11,10 +11,13 @@
11
#define CHART_PRIO 3000
12
13
// #define slabdebug(...) if (debug) { fprintf(stderr, __VA_ARGS__); }
14
-#define slabdebug(args...) if (debug) { \
15
- fprintf(stderr, "slabinfo.plugin DEBUG (%04d@%-10.10s:%-15.15s)::", __LINE__, __FILE__, __FUNCTION__); \
16
- fprintf(stderr, ##args); \
17
- fprintf(stderr, "\n"); }
14
+#define slabdebug(args...) do { \
15
+ if (debug) { \
16
+ fprintf(stderr, "slabinfo.plugin DEBUG (%04d@%-10.10s:%-15.15s)::", __LINE__, __FILE__, __FUNCTION__); \
17
+ fprintf(stderr, ##args); \
18
+ fprintf(stderr, "\n"); \
19
+ } \
20
+} while(0)
21
22
int running = 1;
23
int debug = 0;
collectors/systemd-journal.plugin/systemd-journal-files.c
+1
-1
@@ -93,7 +93,7 @@ static void journal_file_get_header_from_journalctl(const char *filename, struct
93
jf->messages_in_file = jf->last_seqnum - jf->first_seqnum;
94
}
95
96
- if(!jf->logged_journalctl_failure && (!read_head || !read_head || !read_tail)) {
96
+ if(!jf->logged_journalctl_failure && (!read_head || !read_tail)) {
97
98
nd_log(NDLS_COLLECTORS, NDLP_NOTICE,
99
"Failed to read %s%s%s from journalctl's output on filename '%s', using the command: %s",
collectors/systemd-journal.plugin/systemd-journal.c
+1
-1
@@ -1085,7 +1085,7 @@ static bool jf_is_mine(struct journal_file *jf, FUNCTION_QUERY_STATUS *fqs) {
1085
if((fqs->source_type == SDJF_NONE && !fqs->sources) || (jf->source_type & fqs->source_type) ||
1086
(fqs->sources && simple_pattern_matches(fqs->sources, string2str(jf->source)))) {
1087
1088
- if(!jf->msg_last_ut || !jf->msg_last_ut)
1088
+ if(!jf->msg_last_ut)
1089
// the file is not scanned yet, or the timestamps have not been updated,
1090
// so we don't know if it can contribute or not - let's add it.
1091
return true;
daemon/analytics.c
+1
-2
@@ -7,7 +7,6 @@ struct analytics_data analytics_data;
7
extern void analytics_exporting_connectors (BUFFER *b);
8
extern void analytics_exporting_connectors_ssl (BUFFER *b);
9
extern void analytics_build_info (BUFFER *b);
10
-extern int aclk_connected;
10
11
struct collector {
12
const char *plugin;
@@ -483,7 +482,7 @@ void analytics_misc(void)
482
483
if (strcmp(
484
config_get(CONFIG_SECTION_REGISTRY, "registry to announce", "https://registry.my-netdata.io"),
486
- "https://registry.my-netdata.io"))
485
+ "https://registry.my-netdata.io") != 0)
486
analytics_set_data(&analytics_data.netdata_config_use_private_registry, "true");
487
488
//do we need both registry to announce and enabled to indicate that this is a private registry ?
daemon/buildinfo.c
+2
-2
@@ -1499,7 +1499,7 @@ void print_build_info(void) {
1499
print_build_info_category_to_console(BIC_PLUGINS, "Plugins");
1500
print_build_info_category_to_console(BIC_EXPORTERS, "Exporters");
1501
print_build_info_category_to_console(BIC_DEBUG_DEVEL, "Debug/Developer Features");
1502
-};
1502
+}
1503
1504
void build_info_to_json_object(BUFFER *b) {
1505
populate_packaging_info();
@@ -1533,7 +1533,7 @@ void print_build_info_json(void) {
1533
buffer_json_finalize(b);
1534
printf("%s\n", buffer_tostring(b));
1535
buffer_free(b);
1536
-};
1536
+}
1537
1538
void analytics_build_info(BUFFER *b) {
1539
populate_packaging_info();
daemon/commands.c
+3
-3
@@ -499,15 +499,15 @@ static void parse_commands(struct command_context *cmd_ctx)
499
status = CMD_STATUS_FAILURE;
500
501
/* Skip white-space characters */
502
- for (pos = cmd_ctx->command_string ; isspace(*pos) && ('\0' != *pos) ; ++pos) {;}
502
+ for (pos = cmd_ctx->command_string ; isspace(*pos) && ('\0' != *pos) ; ++pos) ;
503
for (i = 0 ; i < CMD_TOTAL_COMMANDS ; ++i) {
504
if (!strncmp(pos, command_info_array[i].cmd_str, strlen(command_info_array[i].cmd_str))) {
505
if (CMD_EXIT == i) {
506
/* musl C does not like libuv workqueues calling exit() */
507
execute_command(CMD_EXIT, NULL, NULL);
508
}
509
- for (lstrip=pos + strlen(command_info_array[i].cmd_str); isspace(*lstrip) && ('\0' != *lstrip); ++lstrip) {;}
510
- for (rstrip=lstrip+strlen(lstrip)-1; rstrip>lstrip && isspace(*rstrip); *(rstrip--) = 0 );
509
+ for (lstrip=pos + strlen(command_info_array[i].cmd_str); isspace(*lstrip) && ('\0' != *lstrip); ++lstrip) ;
510
+ for (rstrip=lstrip+strlen(lstrip)-1; rstrip>lstrip && isspace(*rstrip); *(rstrip--) = 0 ) ;
511
512
cmd_ctx->work.data = cmd_ctx;
513
cmd_ctx->idx = i;
daemon/daemon.c
+1
-1
@@ -274,7 +274,7 @@ static void process_nice_level(void) {
274
else
275
netdata_log_debug(D_SYSTEM, "Set netdata nice level to %d.", nice_level);
276
#endif // HAVE_NICE
277
-};
277
+}
278
279
#define SCHED_FLAG_NONE 0x00
280
#define SCHED_FLAG_PRIORITY_CONFIGURABLE 0x01 // the priority is user configurable
daemon/daemon.h
-1
@@ -8,7 +8,6 @@ int become_user(const char *username, int pid_fd);
8
int become_daemon(int dont_fork, const char *user);
9
10
void netdata_cleanup_and_exit(int i);
11
-void send_statistics(const char *action, const char *action_result, const char *action_data);
11
12
void get_netdata_execution_path(void);
13
daemon/global_statistics.c
+32
-31
@@ -4306,25 +4306,25 @@ void *global_statistics_workers_main(void *ptr)
4306
{
4307
global_statistics_register_workers();
4308
4309
- netdata_thread_cleanup_push(global_statistics_workers_cleanup, ptr);
4310
-
4311
- int update_every =
4312
- (int)config_get_number(CONFIG_SECTION_GLOBAL_STATISTICS, "update every", localhost->rrd_update_every);
4313
- if (update_every < localhost->rrd_update_every)
4314
- update_every = localhost->rrd_update_every;
4315
-
4316
- usec_t step = update_every * USEC_PER_SEC;
4317
- heartbeat_t hb;
4318
- heartbeat_init(&hb);
4309
+ netdata_thread_cleanup_push(global_statistics_workers_cleanup, ptr)
4310
+ {
4311
+ int update_every =
4312
+ (int)config_get_number(CONFIG_SECTION_GLOBAL_STATISTICS, "update every", localhost->rrd_update_every);
4313
+ if (update_every < localhost->rrd_update_every)
4314
+ update_every = localhost->rrd_update_every;
4315
4320
- while (service_running(SERVICE_COLLECTORS)) {
4321
- worker_is_idle();
4322
- heartbeat_next(&hb, step);
4316
+ usec_t step = update_every * USEC_PER_SEC;
4317
+ heartbeat_t hb;
4318
+ heartbeat_init(&hb);
4319
4324
- worker_is_busy(WORKER_JOB_WORKERS);
4325
- worker_utilization_charts();
4326
- }
4320
+ while (service_running(SERVICE_COLLECTORS)) {
4321
+ worker_is_idle();
4322
+ heartbeat_next(&hb, step);
4323
4324
+ worker_is_busy(WORKER_JOB_WORKERS);
4325
+ worker_utilization_charts();
4326
+ }
4327
+ }
4328
netdata_thread_cleanup_pop(1);
4329
return NULL;
4330
}
@@ -4348,25 +4348,26 @@ void *global_statistics_sqlite3_main(void *ptr)
4348
{
4349
global_statistics_register_workers();
4350
4351
- netdata_thread_cleanup_push(global_statistics_sqlite3_cleanup, ptr);
4352
-
4353
- int update_every =
4354
- (int)config_get_number(CONFIG_SECTION_GLOBAL_STATISTICS, "update every", localhost->rrd_update_every);
4355
- if (update_every < localhost->rrd_update_every)
4356
- update_every = localhost->rrd_update_every;
4351
+ netdata_thread_cleanup_push(global_statistics_sqlite3_cleanup, ptr)
4352
+ {
4353
4358
- usec_t step = update_every * USEC_PER_SEC;
4359
- heartbeat_t hb;
4360
- heartbeat_init(&hb);
4354
+ int update_every =
4355
+ (int)config_get_number(CONFIG_SECTION_GLOBAL_STATISTICS, "update every", localhost->rrd_update_every);
4356
+ if (update_every < localhost->rrd_update_every)
4357
+ update_every = localhost->rrd_update_every;
4358
4362
- while (service_running(SERVICE_COLLECTORS)) {
4363
- worker_is_idle();
4364
- heartbeat_next(&hb, step);
4359
+ usec_t step = update_every * USEC_PER_SEC;
4360
+ heartbeat_t hb;
4361
+ heartbeat_init(&hb);
4362
4366
- worker_is_busy(WORKER_JOB_SQLITE3);
4367
- sqlite3_statistics_charts();
4368
- }
4363
+ while (service_running(SERVICE_COLLECTORS)) {
4364
+ worker_is_idle();
4365
+ heartbeat_next(&hb, step);
4366
4367
+ worker_is_busy(WORKER_JOB_SQLITE3);
4368
+ sqlite3_statistics_charts();
4369
+ }
4370
+ }
4371
netdata_thread_cleanup_pop(1);
4372
return NULL;
4373
}
daemon/main.c
+2
-2
@@ -296,7 +296,7 @@ static bool service_wait_exit(SERVICE_TYPE service, usec_t timeout_ut) {
296
}
297
298
#define delta_shutdown_time(msg) \
299
- { \
299
+ do { \
300
usec_t now_ut = now_monotonic_usec(); \
301
if(prev_msg) \
302
netdata_log_info("NETDATA SHUTDOWN: in %7llu ms, %s%s - next: %s", (now_ut - last_ut) / USEC_PER_MS, (timeout)?"(TIMEOUT) ":"", prev_msg, msg); \
@@ -305,7 +305,7 @@ static bool service_wait_exit(SERVICE_TYPE service, usec_t timeout_ut) {
305
last_ut = now_ut; \
306
prev_msg = msg; \
307
timeout = false; \
308
- }
308
+ } while(0)
309
310
void web_client_cache_destroy(void);
311
daemon/main.h
-1
@@ -25,7 +25,6 @@ struct option_def {
25
void cancel_main_threads(void);
26
int killpid(pid_t pid);
27
void netdata_cleanup_and_exit(int ret) NORETURN;
28
-void send_statistics(const char *action, const char *action_result, const char *action_data);
28
29
typedef enum {
30
ABILITY_DATA_QUERIES = (1 << 0),
database/contexts/instance.c
+1
-1
@@ -404,7 +404,7 @@ inline void rrdinstance_from_rrdset(RRDSET *st) {
404
fatal("RRDCONTEXT: cannot switch rrdcontext without switching rrdinstance too");
405
}
406
407
-#define rrdset_get_rrdinstance(st) rrdset_get_rrdinstance_with_trace(st, __FUNCTION__);
407
+#define rrdset_get_rrdinstance(st) rrdset_get_rrdinstance_with_trace(st, __FUNCTION__)
408
static inline RRDINSTANCE *rrdset_get_rrdinstance_with_trace(RRDSET *st, const char *function) {
409
if(unlikely(!st->rrdcontexts.rrdinstance)) {
410
netdata_log_error("RRDINSTANCE: RRDSET '%s' is not linked to an RRDINSTANCE at %s()", rrdset_id(st), function);
database/contexts/query_target.c
+1
-1
@@ -4,7 +4,7 @@
4
5
#define QUERY_TARGET_MAX_REALLOC_INCREASE 500
6
#define query_target_realloc_size(size, start) \
7
- (size) ? ((size) < QUERY_TARGET_MAX_REALLOC_INCREASE ? (size) * 2 : (size) + QUERY_TARGET_MAX_REALLOC_INCREASE) : (start);
7
+ (size) ? ((size) < QUERY_TARGET_MAX_REALLOC_INCREASE ? (size) * 2 : (size) + QUERY_TARGET_MAX_REALLOC_INCREASE) : (start)
8
9
static void query_metric_release(QUERY_TARGET *qt, QUERY_METRIC *qm);
10
static void query_dimension_release(QUERY_DIMENSION *qd);
database/engine/journalfile.c
+6
-3
@@ -637,9 +637,12 @@ static int journalfile_check_superblock(uv_file file)
637
fatal_assert(req.result >= 0);
638
uv_fs_req_cleanup(&req);
639
640
- if (strncmp(superblock->magic_number, RRDENG_JF_MAGIC, RRDENG_MAGIC_SZ) ||
641
- strncmp(superblock->version, RRDENG_JF_VER, RRDENG_VER_SZ)) {
642
- netdata_log_error("DBENGINE: File has invalid superblock.");
640
+
641
+ char jf_magic[RRDENG_MAGIC_SZ] = RRDENG_JF_MAGIC;
642
+ char jf_ver[RRDENG_VER_SZ] = RRDENG_JF_VER;
643
+ if (strncmp(superblock->magic_number, jf_magic, RRDENG_MAGIC_SZ) != 0 ||
644
+ strncmp(superblock->version, jf_ver, RRDENG_VER_SZ) != 0) {
645
+ nd_log(NDLS_DAEMON, NDLP_ERR, "DBENGINE: File has invalid superblock.");
646
ret = UV_EINVAL;
647
} else {
648
ret = 0;
database/engine/journalfile.h
-1
@@ -7,7 +7,6 @@
7
8
/* Forward declarations */
9
struct rrdengine_instance;
10
-struct rrdengine_worker_config;
10
struct rrdengine_datafile;
11
struct rrdengine_journalfile;
12
database/engine/pagecache.h
-2
@@ -14,8 +14,6 @@ extern struct pgc *extent_cache;
14
struct rrdengine_instance;
15
16
#define INVALID_TIME (0)
17
-#define MAX_PAGE_CACHE_FETCH_RETRIES (3)
18
-#define PAGE_CACHE_FETCH_WAIT_TIMEOUT (3)
17
18
extern struct rrdeng_cache_efficiency_stats rrdeng_cache_efficiency_stats;
19
database/engine/rrdenginelib.h
-7
@@ -8,16 +8,9 @@
8
/* Forward declarations */
9
struct rrdengine_instance;
10
11
-#define STR_HELPER(x) #x
12
-#define STR(x) STR_HELPER(x)
13
-
14
-#define BITS_PER_ULONG (sizeof(unsigned long) * 8)
15
-
11
#define ALIGN_BYTES_FLOOR(x) (((x) / RRDENG_BLOCK_SIZE) * RRDENG_BLOCK_SIZE)
12
#define ALIGN_BYTES_CEILING(x) ((((x) + RRDENG_BLOCK_SIZE - 1) / RRDENG_BLOCK_SIZE) * RRDENG_BLOCK_SIZE)
13
19
-#define ROUND_USEC_TO_SEC(x) (((x) + USEC_PER_SEC / 2 - 1) / USEC_PER_SEC)
20
-
14
typedef uintptr_t rrdeng_stats_t;
15
16
#ifdef __ATOMIC_RELAXED
database/rrd.h
-1
@@ -197,7 +197,6 @@ extern bool ieee754_doubles;
197
#define RRD_ID_LENGTH_MAX 1000
198
199
typedef long long total_number;
200
-#define TOTAL_NUMBER_FORMAT "%lld"
200
201
// ----------------------------------------------------------------------------
202
// algorithms types
database/sqlite/sqlite_functions.c
+4
-5
@@ -725,7 +725,7 @@ struct node_instance_list *get_node_list(void)
725
if (unlikely(rc != SQLITE_OK)) {
726
error_report("Failed to prepare statement to get node instance information");
727
return NULL;
728
- };
728
+ }
729
730
int row = 0;
731
char host_guid[37];
@@ -774,7 +774,7 @@ failed:
774
error_report("Failed to finalize the prepared statement when fetching node instance information");
775
776
return node_list;
777
-};
777
+}
778
779
#define SQL_GET_HOST_NODE_ID "SELECT node_id FROM node_instance WHERE host_id = @host_id"
780
@@ -793,7 +793,7 @@ void sql_load_node_id(RRDHOST *host)
793
if (unlikely(rc != SQLITE_OK)) {
794
error_report("Failed to prepare statement to fetch node id");
795
return;
796
- };
796
+ }
797
798
rc = sqlite3_bind_blob(res, 1, &host->host_uuid, sizeof(host->host_uuid), SQLITE_STATIC);
799
if (unlikely(rc != SQLITE_OK)) {
@@ -812,8 +812,7 @@ void sql_load_node_id(RRDHOST *host)
812
failed:
813
if (unlikely(sqlite3_finalize(res) != SQLITE_OK))
814
error_report("Failed to finalize the prepared statement when loading node instance information");
815
-};
816
-
815
+}
816
817
#define SELECT_HOST_INFO "SELECT system_key, system_value FROM host_info WHERE host_id = @host_id"
818
exporting/prometheus/prometheus.c
-1
@@ -1,6 +1,5 @@
1
// SPDX-License-Identifier: GPL-3.0-or-later
2
3
-#define EXPORTINGS_INTERNALS
3
#include "prometheus.h"
4
5
// ----------------------------------------------------------------------------
exporting/prometheus/prometheus.h
-2
@@ -9,8 +9,6 @@
9
#define PROMETHEUS_LABELS_MAX 1024
10
#define PROMETHEUS_VARIABLE_MAX 256
11
12
-#define PROMETHEUS_LABELS_MAX_NUMBER 128
13
-
12
typedef enum prometheus_output_flags {
13
PROMETHEUS_OUTPUT_NONE = 0,
14
PROMETHEUS_OUTPUT_HELP = (1 << 0),
libnetdata/clocks/clocks.c
+1
-1
@@ -230,7 +230,7 @@ void sleep_to_absolute_time(usec_t usec) {
230
sleep_usec(usec);
231
}
232
}
233
-};
233
+}
234
#endif
235
236
#define HEARTBEAT_ALIGNMENT_STATISTICS_SIZE 10
libnetdata/clocks/clocks.h
+1
-1
@@ -143,7 +143,7 @@ usec_t heartbeat_next(heartbeat_t *hb, usec_t tick);
143
void heartbeat_statistics(usec_t *min_ptr, usec_t *max_ptr, usec_t *average_ptr, size_t *count_ptr);
144
145
void sleep_usec_with_now(usec_t usec, usec_t started_ut);
146
-#define sleep_usec(usec) sleep_usec_with_now(usec, 0);
146
+#define sleep_usec(usec) sleep_usec_with_now(usec, 0)
147
148
void clocks_init(void);
149
libnetdata/dictionary/dictionary.h
+1
-1
@@ -303,7 +303,7 @@ typedef DICTFE_CONST struct dictionary_foreach {
303
dictionary_foreach_done(&value ## _dfe); \
304
} while(0)
305
306
-#define dfe_unlock(value) dictionary_foreach_unlock(&value ## _dfe);
306
+#define dfe_unlock(value) dictionary_foreach_unlock(&value ## _dfe)
307
308
void *dictionary_foreach_start_rw(DICTFE *dfe, DICTIONARY *dict, char rw);
309
void *dictionary_foreach_next(DICTFE *dfe);
libnetdata/ebpf/ebpf.c
+2
-2
@@ -768,7 +768,7 @@ static void ebpf_update_maps(ebpf_module_t *em, struct bpf_object *obj)
768
int fd = bpf_map__fd(map);
769
if (maps) {
770
const char *map_name = bpf_map__name(map);
771
- int j = 0; ;
771
+ int j = 0;
772
while (maps[j].name) {
773
ebpf_local_maps_t *w = &maps[j];
774
if (w->map_fd == ND_EBPF_MAP_FD_NOT_INITIALIZED && !strcmp(map_name, w->name))
@@ -908,7 +908,7 @@ char *ebpf_find_symbol(char *search)
908
unsigned long i, lines = procfile_lines(ff);
909
size_t length = strlen(search);
910
for(i = 0; i < lines ; i++) {
911
- char *cmp = procfile_lineword(ff, i,2);;
911
+ char *cmp = procfile_lineword(ff, i,2);
912
if (!strncmp(search, cmp, length)) {
913
ret = strdupz(cmp);
914
break;
libnetdata/ebpf/ebpf.h
+1
-1
@@ -141,7 +141,7 @@ enum netdata_kernel_idx {
141
#define EBPF_KERNEL_REJECT_LIST_FILE "ebpf_kernel_reject_list.txt"
142
143
#define ND_EBPF_DEFAULT_MIN_PID 1U
144
-#define ND_EBPF_MAP_FD_NOT_INITIALIZED (int)-1
144
+#define ND_EBPF_MAP_FD_NOT_INITIALIZED ((int)-1)
145
146
typedef struct ebpf_addresses {
147
char *function;
libnetdata/libnetdata.h
-9
@@ -43,10 +43,6 @@ extern "C" {
43
//#define NETDATA_TRACE_ALLOCATIONS 1
44
//#endif
45
46
-#define OS_LINUX 1
47
-#define OS_FREEBSD 2
48
-#define OS_MACOS 3
49
-
46
#define MALLOC_ALIGNMENT (sizeof(uintptr_t) * 2)
47
#define size_t_atomic_count(op, var, size) __atomic_## op ##_fetch(&(var), size, __ATOMIC_RELAXED)
48
#define size_t_atomic_bytes(op, var, size) __atomic_## op ##_fetch(&(var), ((size) % MALLOC_ALIGNMENT)?((size) + MALLOC_ALIGNMENT - ((size) % MALLOC_ALIGNMENT)):(size), __ATOMIC_RELAXED)
@@ -203,10 +199,6 @@ extern "C" {
199
200
#define _cleanup_(x) __attribute__((__cleanup__(x)))
201
206
-#ifdef __GNUC__
207
-#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
208
-#endif // __GNUC__
209
-
202
#ifdef HAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL
203
#define NEVERNULL __attribute__((returns_nonnull))
204
#else
@@ -703,7 +695,6 @@ typedef enum {
695
void for_each_open_fd(OPEN_FD_ACTION action, OPEN_FD_EXCLUDE excluded_fds);
696
697
void netdata_cleanup_and_exit(int ret) NORETURN;
706
-void send_statistics(const char *action, const char *action_result, const char *action_data);
698
extern char *netdata_configured_host_prefix;
699
700
#define XXH_INLINE_ALL
libnetdata/log/journal.c
+6
-4
@@ -3,15 +3,12 @@
3
#include "journal.h"
4
5
bool is_path_unix_socket(const char *path) {
6
+ // Check if the path is valid
7
if(!path || !*path)
8
return false;
9
10
struct stat statbuf;
11
11
- // Check if the path is valid
12
- if (!path || !*path)
13
- return false;
14
-
12
// Use stat to check if the file exists and is a socket
13
if (stat(path, &statbuf) == -1)
14
// The file does not exist or cannot be accessed
@@ -97,6 +94,11 @@ static inline bool journal_send_with_memfd(int fd, const char *msg, size_t msg_l
94
msghdr.msg_controllen = sizeof(cmsgbuf);
95
96
cmsghdr = CMSG_FIRSTHDR(&msghdr);
97
+ if(!cmsghdr) {
98
+ close(memfd);
99
+ return false;
100
+ }
101
+
102
cmsghdr->cmsg_level = SOL_SOCKET;
103
cmsghdr->cmsg_type = SCM_RIGHTS;
104
cmsghdr->cmsg_len = CMSG_LEN(sizeof(int));
libnetdata/log/log.c
+6
-4
@@ -1,5 +1,7 @@
1
// SPDX-License-Identifier: GPL-3.0-or-later
2
3
+// do not REMOVE this, it is used by systemd-journal includes to prevent saving the file, function, line of the
4
+// source code that makes the calls, allowing our loggers to log the lines of source code that actually log
5
#define SD_JOURNAL_SUPPRESS_LOCATION
6
7
#include "../libnetdata.h"
@@ -1433,13 +1435,13 @@ static int64_t log_field_to_int64(struct log_field *lf) {
1435
break;
1436
1437
case NDFT_U64:
1436
- return lf->entry.u64;
1438
+ return (int64_t)lf->entry.u64;
1439
1440
case NDFT_I64:
1439
- return lf->entry.i64;
1441
+ return (int64_t)lf->entry.i64;
1442
1443
case NDFT_DBL:
1442
- return lf->entry.dbl;
1444
+ return (int64_t)lf->entry.dbl;
1445
}
1446
1447
if(s && *s)
@@ -1536,7 +1538,7 @@ static void errno_annotator(BUFFER *wb, const char *key, struct log_field *lf) {
1538
return;
1539
1540
char buf[1024];
1539
- const char *s = errno2str(errnum, buf, sizeof(buf));
1541
+ const char *s = errno2str((int)errnum, buf, sizeof(buf));
1542
1543
if(buffer_strlen(wb))
1544
buffer_fast_strcat(wb, " ", 1);
libnetdata/log/log.h
+1
-2
@@ -286,12 +286,11 @@ typedef struct error_with_limit {
286
287
#define nd_log_limit_static_global_var(var, log_every_secs, sleep_usecs) static ERROR_LIMIT var = { .last_logged = 0, .count = 0, .log_every = (log_every_secs), .sleep_ut = (sleep_usecs) }
288
#define nd_log_limit_static_thread_var(var, log_every_secs, sleep_usecs) static __thread ERROR_LIMIT var = { .last_logged = 0, .count = 0, .log_every = (log_every_secs), .sleep_ut = (sleep_usecs) }
289
-void netdata_logger_with_limit(ERROR_LIMIT *erl, ND_LOG_SOURCES source, ND_LOG_FIELD_PRIORITY priority, const char *file, const char *function, unsigned long line, const char *fmt, ... ) PRINTFLIKE(7, 8);;
289
+void netdata_logger_with_limit(ERROR_LIMIT *erl, ND_LOG_SOURCES source, ND_LOG_FIELD_PRIORITY priority, const char *file, const char *function, unsigned long line, const char *fmt, ... ) PRINTFLIKE(7, 8);
290
#define nd_log_limit(erl, NDLS, NDLP, args...) netdata_logger_with_limit(erl, NDLS, NDLP, __FILE__, __FUNCTION__, __LINE__, ##args)
291
292
// ----------------------------------------------------------------------------
293
294
-void send_statistics(const char *action, const char *action_result, const char *action_data);
294
void netdata_logger_fatal( const char *file, const char *function, unsigned long line, const char *fmt, ... ) NORETURN PRINTFLIKE(4, 5);
295
296
# ifdef __cplusplus
libnetdata/onewayalloc/onewayalloc.c
-2
@@ -178,8 +178,6 @@ void onewayalloc_freez(ONEWAYALLOC *owa __maybe_unused, const void *ptr __maybe_
178
// let's free it with the system allocator
179
netdata_log_error("ONEWAYALLOC: request to free address 0x%p that is not allocated by this OWA", ptr);
180
#endif
181
-
182
- return;
181
}
182
183
void *onewayalloc_doublesize(ONEWAYALLOC *owa, const void *src, size_t oldsize) {
libnetdata/required_dummies.h
+9
-10
@@ -14,13 +14,12 @@ void send_statistics(const char *action, const char *action_result, const char *
14
(void)action;
15
(void)action_result;
16
(void)action_data;
17
- return;
17
}
18
19
// callbacks required by popen()
21
-void signals_block(void){};
22
-void signals_unblock(void){};
23
-void signals_reset(void){};
20
+void signals_block(void){}
21
+void signals_unblock(void){}
22
+void signals_reset(void){}
23
24
#ifndef UNIT_TESTING
25
// callback required by eval()
@@ -30,14 +29,14 @@ int health_variable_lookup(STRING *variable, struct rrdcalc *rc, NETDATA_DOUBLE
29
(void)rc;
30
(void)result;
31
return 0;
33
-};
32
+}
33
#endif
34
36
-void rrdset_thread_rda_free(void){};
37
-void sender_thread_buffer_free(void){};
38
-void query_target_free(void){};
39
-void service_exits(void){};
40
-void rrd_collector_finished(void){};
35
+void rrdset_thread_rda_free(void){}
36
+void sender_thread_buffer_free(void){}
37
+void query_target_free(void){}
38
+void service_exits(void){}
39
+void rrd_collector_finished(void){}
40
41
// required by get_system_cpus()
42
char *netdata_configured_host_prefix = "";
libnetdata/simple_pattern/simple_pattern.c
+1
-1
@@ -147,7 +147,7 @@ SIMPLE_PATTERN *simple_pattern_create(const char *list, const char *separators,
147
if(default_mode == SIMPLE_PATTERN_SUBSTRING) {
148
m->mode = SIMPLE_PATTERN_SUBSTRING;
149
150
- struct simple_pattern *tm = m;
150
+ struct simple_pattern *tm;
151
for(tm = m; tm->child ; tm = tm->child) ;
152
tm->mode = SIMPLE_PATTERN_SUBSTRING;
153
}
libnetdata/socket/socket.c
+1
-1
@@ -549,7 +549,7 @@ static inline int bind_to_this(LISTEN_SOCKETS *sockets, const char *definition,
549
char buffer2[10 + 1];
550
snprintfz(buffer2, 10, "%d", default_port);
551
552
- char *ip = buffer, *port = buffer2, *interface = "", *portconfig;;
552
+ char *ip = buffer, *port = buffer2, *interface = "", *portconfig;
553
554
int protocol = IPPROTO_TCP, socktype = SOCK_STREAM;
555
const char *protocol_str = "tcp";
libnetdata/string/string.c
+2
-2
@@ -88,8 +88,8 @@ void string_statistics(size_t *inserts, size_t *deletes, size_t *searches, size_
88
}
89
}
90
91
-#define string_entry_acquire(se) __atomic_add_fetch(&((se)->refcount), 1, __ATOMIC_SEQ_CST);
92
-#define string_entry_release(se) __atomic_sub_fetch(&((se)->refcount), 1, __ATOMIC_SEQ_CST);
91
+#define string_entry_acquire(se) __atomic_add_fetch(&((se)->refcount), 1, __ATOMIC_SEQ_CST)
92
+#define string_entry_release(se) __atomic_sub_fetch(&((se)->refcount), 1, __ATOMIC_SEQ_CST)
93
94
static inline bool string_entry_check_and_acquire(STRING *se) {
95
#ifdef NETDATA_INTERNAL_CHECKS
libnetdata/threads/threads.c
+3
-2
@@ -276,8 +276,9 @@ static void *netdata_thread_init(void *ptr) {
276
netdata_thread_set_tag(netdata_thread->tag);
277
278
void *ret = NULL;
279
- pthread_cleanup_push(thread_cleanup, ptr);
280
- ret = netdata_thread->start_routine(netdata_thread->arg);
279
+ pthread_cleanup_push(thread_cleanup, ptr) {
280
+ ret = netdata_thread->start_routine(netdata_thread->arg);
281
+ }
282
pthread_cleanup_pop(1);
283
284
return ret;
logsmanagement/circular_buffer.c
+1
-1
@@ -401,4 +401,4 @@ void circ_buff_destroy(Circ_buff_t *buff){
401
freez(buff->in->data);
402
freez(buff->in);
403
freez(buff);
404
-};
404
+}
logsmanagement/db_api.c
+2
-2
@@ -146,7 +146,7 @@ static void db_writer_db_mode_none(void *arg){
146
}
147
}
148
149
-#define return_db_writer_db_mode_none(p_file_info, do_mut_unlock){ \
149
+#define return_db_writer_db_mode_none(p_file_info, do_mut_unlock) do { \
150
p_file_info->db_mode = LOGS_MANAG_DB_MODE_NONE; \
151
freez((void *) p_file_info->db_dir); \
152
p_file_info->db_dir = strdupz(""); \
@@ -165,7 +165,7 @@ static void db_writer_db_mode_none(void *arg){
165
return fatal_assert(!uv_thread_create( p_file_info->db_writer_thread, \
166
db_writer_db_mode_none, \
167
p_file_info)); \
168
-}
168
+} while(0)
169
170
static void db_writer_db_mode_full(void *arg){
171
int rc = 0;
logsmanagement/logsmanag_config.c
+4
-4
@@ -679,7 +679,7 @@ static void config_section_init(uv_loop_t *main_loop,
679
NULL
680
};
681
int i = 0;
682
- while(auth_path_default[i] && access(auth_path_default[i], R_OK)){i++;};
682
+ while(auth_path_default[i] && access(auth_path_default[i], R_OK)) i++;
683
if(!auth_path_default[i]){
684
collector_error("[%s]: auth.log path invalid, unknown or needs permissions", p_file_info->chartname);
685
return p_file_info_destroy(p_file_info);
@@ -691,7 +691,7 @@ static void config_section_init(uv_loop_t *main_loop,
691
NULL
692
};
693
int i = 0;
694
- while(syslog_path_default[i] && access(syslog_path_default[i], R_OK)){i++;};
694
+ while(syslog_path_default[i] && access(syslog_path_default[i], R_OK)) i++;
695
if(!syslog_path_default[i]){
696
collector_error("[%s]: syslog path invalid, unknown or needs permissions", p_file_info->chartname);
697
return p_file_info_destroy(p_file_info);
@@ -709,7 +709,7 @@ static void config_section_init(uv_loop_t *main_loop,
709
NULL
710
};
711
int i = 0;
712
- while(apache_access_path_default[i] && access(apache_access_path_default[i], R_OK)){i++;};
712
+ while(apache_access_path_default[i] && access(apache_access_path_default[i], R_OK)) i++;
713
if(!apache_access_path_default[i]){
714
collector_error("[%s]: Apache access.log path invalid, unknown or needs permissions", p_file_info->chartname);
715
return p_file_info_destroy(p_file_info);
@@ -720,7 +720,7 @@ static void config_section_init(uv_loop_t *main_loop,
720
NULL
721
};
722
int i = 0;
723
- while(nginx_access_path_default[i] && access(nginx_access_path_default[i], R_OK)){i++;};
723
+ while(nginx_access_path_default[i] && access(nginx_access_path_default[i], R_OK)) i++;
724
if(!nginx_access_path_default[i]){
725
collector_error("[%s]: Nginx access.log path invalid, unknown or needs permissions", p_file_info->chartname);
726
return p_file_info_destroy(p_file_info);
logsmanagement/parser.c
+5
-5
@@ -64,7 +64,7 @@ UNIT_STATIC int count_fields(const char *line, const char delimiter){
64
}
65
if(*ptr == delimiter){
66
cnt++;
67
- while(*(ptr+1) == delimiter){ ptr++;};
67
+ while(*(ptr+1) == delimiter) ptr++;
68
continue;
69
}
70
}
@@ -228,7 +228,7 @@ int search_keyword( char *src, size_t src_sz __maybe_unused,
228
regerror(rc, ®ex_compiled, regcomp_err_str, regcomp_err_str_size);
229
freez(regcomp_err_str);
230
fatal("Could not compile regular expression:%.*s, error: %s", (int) MAX_REGEX_SIZE, regexString, regcomp_err_str);
231
- };
231
+ }
232
}
233
234
regmatch_t groupArray[1];
@@ -477,8 +477,8 @@ void parse_web_log_line(const Web_log_parser_config_t *wblp_config,
477
goto next_item;
478
}
479
480
- while(*port != ':' && vhost_size < field_size) { port++; vhost_size++; };
481
- if(likely(vhost_size < field_size)){
480
+ while(*port != ':' && vhost_size < field_size) { port++; vhost_size++; }
481
+ if(likely(vhost_size < field_size)) {
482
/* ':' detected in string */
483
port++;
484
port_size = field_size - vhost_size - 1;
@@ -1122,7 +1122,7 @@ void parse_web_log_line(const Web_log_parser_config_t *wblp_config,
1122
if(fields_format[i] == TIME){
1123
1124
if(wblp_config->skip_timestamp_parsing){
1125
- while(*offset != ']') {offset++;};
1125
+ while(*offset != ']') offset++;
1126
i++;
1127
offset++;
1128
goto next_item;
logsmanagement/rrd_api/rrd_api.h
+8
-8
@@ -145,7 +145,7 @@ static inline void lgs_mng_update_chart_end(time_t sec){
145
printf("END %" PRId64 " 0 1\n", sec);
146
}
147
148
-#define lgs_mng_do_num_of_logs_charts_init(p_file_info, chart_prio){ \
148
+#define lgs_mng_do_num_of_logs_charts_init(p_file_info, chart_prio) do { \
149
\
150
/* Number of collected logs total - initialise */ \
151
if(p_file_info->parser_config->chart_config & CHART_COLLECTED_LOGS_TOTAL){ \
@@ -179,9 +179,9 @@ static inline void lgs_mng_update_chart_end(time_t sec){
179
lgs_mng_add_dim("records", RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1); \
180
} \
181
\
182
-} \
182
+} while(0)
183
184
-#define lgs_mng_do_num_of_logs_charts_update(p_file_info, lag_in_sec, chart_data){ \
184
+#define lgs_mng_do_num_of_logs_charts_update(p_file_info, lag_in_sec, chart_data) do { \
185
\
186
/* Number of collected logs total - update previous values */ \
187
if(p_file_info->parser_config->chart_config & CHART_COLLECTED_LOGS_TOTAL){ \
@@ -220,9 +220,9 @@ static inline void lgs_mng_update_chart_end(time_t sec){
220
lgs_mng_update_chart_set("records", chart_data->num_lines); \
221
lgs_mng_update_chart_end(p_file_info->parser_metrics->last_update); \
222
} \
223
-}
223
+} while(0)
224
225
-#define lgs_mng_do_custom_charts_init(p_file_info) { \
225
+#define lgs_mng_do_custom_charts_init(p_file_info) do { \
226
\
227
for(int cus_off = 0; p_file_info->parser_cus_config[cus_off]; cus_off++){ \
228
\
@@ -269,9 +269,9 @@ static inline void lgs_mng_update_chart_end(time_t sec){
269
RRD_ALGORITHM_INCREMENTAL_NAME, 1, 1); \
270
\
271
} \
272
-}
272
+} while(0)
273
274
-#define lgs_mng_do_custom_charts_update(p_file_info, lag_in_sec) { \
274
+#define lgs_mng_do_custom_charts_update(p_file_info, lag_in_sec) do { \
275
\
276
for(time_t sec = p_file_info->parser_metrics->last_update - lag_in_sec; \
277
sec < p_file_info->parser_metrics->last_update; \
@@ -307,6 +307,6 @@ static inline void lgs_mng_update_chart_end(time_t sec){
307
\
308
lgs_mng_update_chart_end(p_file_info->parser_metrics->last_update); \
309
} \
310
-}
310
+} while(0)
311
312
#endif // RRD_API_H_
streaming/receiver.c
+40
-45
@@ -308,64 +308,59 @@ static size_t streaming_parser(struct receiver_state *rpt, struct plugind *cd, i
308
309
// this keeps the parser with its current value
310
// so, parser needs to be allocated before pushing it
311
- netdata_thread_cleanup_push(pluginsd_process_thread_cleanup, parser);
312
-
313
- {
314
- bool compressed_connection = rrdpush_decompression_initialize(rpt);
315
-
316
- buffered_reader_init(&rpt->reader);
311
+ netdata_thread_cleanup_push(pluginsd_process_thread_cleanup, parser) {
312
+ bool compressed_connection = rrdpush_decompression_initialize(rpt);
313
+ buffered_reader_init(&rpt->reader);
314
315
#ifdef NETDATA_LOG_STREAM_RECEIVE
319
- {
320
- char filename[FILENAME_MAX + 1];
321
- snprintfz(filename, FILENAME_MAX, "/tmp/stream-receiver-%s.txt", rpt->host ? rrdhost_hostname(
322
- rpt->host) : "unknown"
323
- );
324
- parser->user.stream_log_fp = fopen(filename, "w");
325
- parser->user.stream_log_repertoire = PARSER_REP_METADATA;
326
- }
316
+ {
317
+ char filename[FILENAME_MAX + 1];
318
+ snprintfz(filename, FILENAME_MAX, "/tmp/stream-receiver-%s.txt", rpt->host ? rrdhost_hostname(
319
+ rpt->host) : "unknown"
320
+ );
321
+ parser->user.stream_log_fp = fopen(filename, "w");
322
+ parser->user.stream_log_repertoire = PARSER_REP_METADATA;
323
+ }
324
#endif
325
329
- CLEAN_BUFFER *buffer = buffer_create(sizeof(rpt->reader.read_buffer), NULL);
330
-
331
- ND_LOG_STACK lgs[] = {
332
- ND_LOG_FIELD_CB(NDF_REQUEST, line_splitter_reconstruct_line, &parser->line),
333
- ND_LOG_FIELD_CB(NDF_NIDL_NODE, parser_reconstruct_node, parser),
334
- ND_LOG_FIELD_CB(NDF_NIDL_INSTANCE, parser_reconstruct_instance, parser),
335
- ND_LOG_FIELD_CB(NDF_NIDL_CONTEXT, parser_reconstruct_context, parser),
336
- ND_LOG_FIELD_END(),
337
- };
338
- ND_LOG_STACK_PUSH(lgs);
326
+ CLEAN_BUFFER *buffer = buffer_create(sizeof(rpt->reader.read_buffer), NULL);
327
340
- while(!receiver_should_stop(rpt)) {
328
+ ND_LOG_STACK lgs[] = {
329
+ ND_LOG_FIELD_CB(NDF_REQUEST, line_splitter_reconstruct_line, &parser->line),
330
+ ND_LOG_FIELD_CB(NDF_NIDL_NODE, parser_reconstruct_node, parser),
331
+ ND_LOG_FIELD_CB(NDF_NIDL_INSTANCE, parser_reconstruct_instance, parser),
332
+ ND_LOG_FIELD_CB(NDF_NIDL_CONTEXT, parser_reconstruct_context, parser),
333
+ ND_LOG_FIELD_END(),
334
+ };
335
+ ND_LOG_STACK_PUSH(lgs);
336
342
- if(!buffered_reader_next_line(&rpt->reader, buffer)) {
343
- STREAM_HANDSHAKE reason = STREAM_HANDSHAKE_DISCONNECT_UNKNOWN_SOCKET_READ_ERROR;
337
+ while(!receiver_should_stop(rpt)) {
338
345
- bool have_new_data = compressed_connection ? receiver_read_compressed(rpt, &reason)
346
- : receiver_read_uncompressed(rpt, &reason);
339
+ if(!buffered_reader_next_line(&rpt->reader, buffer)) {
340
+ STREAM_HANDSHAKE reason = STREAM_HANDSHAKE_DISCONNECT_UNKNOWN_SOCKET_READ_ERROR;
341
348
- if(unlikely(!have_new_data)) {
349
- receiver_set_exit_reason(rpt, reason, false);
350
- break;
351
- }
342
+ bool have_new_data = compressed_connection ? receiver_read_compressed(rpt, &reason)
343
+ : receiver_read_uncompressed(rpt, &reason);
344
353
- continue;
354
- }
345
+ if(unlikely(!have_new_data)) {
346
+ receiver_set_exit_reason(rpt, reason, false);
347
+ break;
348
+ }
349
356
- if(unlikely(parser_action(parser, buffer->buffer))) {
357
- receiver_set_exit_reason(rpt, STREAM_HANDSHAKE_DISCONNECT_PARSER_FAILED, false);
358
- break;
359
- }
350
+ continue;
351
+ }
352
361
- buffer->len = 0;
362
- buffer->buffer[0] = '\0';
363
- }
364
- result = parser->user.data_collections_count;
353
+ if(unlikely(parser_action(parser, buffer->buffer))) {
354
+ receiver_set_exit_reason(rpt, STREAM_HANDSHAKE_DISCONNECT_PARSER_FAILED, false);
355
+ break;
356
}
357
367
- // free parser with the pop function
368
- netdata_thread_cleanup_pop(1);
358
+ buffer->len = 0;
359
+ buffer->buffer[0] = '\0';
360
+ }
361
+ result = parser->user.data_collections_count;
362
+ }
363
+ netdata_thread_cleanup_pop(1); // free parser with the pop function
364
365
return result;
366
}
streaming/replication.c
+9
-10
@@ -1426,7 +1426,7 @@ static void replication_request_delete_callback(const DICTIONARY_ITEM *item __ma
1426
1427
static bool sender_is_still_connected_for_this_request(struct replication_request *rq) {
1428
return rq->sender_last_flush_ut == rrdpush_sender_get_flush_time(rq->sender);
1429
-};
1429
+}
1430
1431
static bool replication_execute_request(struct replication_request *rq, bool workers) {
1432
bool ret = false;
@@ -1838,17 +1838,16 @@ static void replication_worker_cleanup(void *ptr __maybe_unused) {
1838
static void *replication_worker_thread(void *ptr) {
1839
replication_initialize_workers(false);
1840
1841
- netdata_thread_cleanup_push(replication_worker_cleanup, ptr);
1842
-
1843
- while(service_running(SERVICE_REPLICATION)) {
1844
- if(unlikely(replication_pipeline_execute_next() == REQUEST_QUEUE_EMPTY)) {
1845
- sender_thread_buffer_free();
1846
- worker_is_busy(WORKER_JOB_WAIT);
1847
- worker_is_idle();
1848
- sleep_usec(1 * USEC_PER_SEC);
1841
+ netdata_thread_cleanup_push(replication_worker_cleanup, ptr) {
1842
+ while (service_running(SERVICE_REPLICATION)) {
1843
+ if (unlikely(replication_pipeline_execute_next() == REQUEST_QUEUE_EMPTY)) {
1844
+ sender_thread_buffer_free();
1845
+ worker_is_busy(WORKER_JOB_WAIT);
1846
+ worker_is_idle();
1847
+ sleep_usec(1 * USEC_PER_SEC);
1848
+ }
1849
}
1850
}
1851
-
1851
netdata_thread_cleanup_pop(1);
1852
return NULL;
1853
}
streaming/rrdpush.c
+12
-25
@@ -485,20 +485,11 @@ void rrdset_push_metrics_finished(RRDSET_STREAM_BUFFER *rsb, RRDSET *st) {
485
*rsb = (RRDSET_STREAM_BUFFER){ .wb = NULL, };
486
}
487
488
-// TODO enable this macro before release
489
-#define bail_if_no_cap(cap) \
490
- if(unlikely(!stream_has_capability(host->sender, cap))) { \
491
- return; \
492
- }
493
-
494
-#define dyncfg_check_can_push(host) \
495
- if(unlikely(!rrdhost_can_send_definitions_to_parent(host))) \
496
- return; \
497
- bail_if_no_cap(STREAM_CAP_DYNCFG)
488
+#define dyncfg_can_push(host) (rrdhost_can_send_definitions_to_parent(host) && stream_has_capability((host)->sender, STREAM_CAP_DYNCFG))
489
490
// assumes job is locked and acquired!!!
491
void rrdpush_send_job_status_update(RRDHOST *host, const char *plugin_name, const char *module_name, struct job *job) {
501
- dyncfg_check_can_push(host);
492
+ if(!dyncfg_can_push(host)) return;
493
494
BUFFER *wb = sender_start(host->sender);
495
@@ -517,7 +508,7 @@ void rrdpush_send_job_status_update(RRDHOST *host, const char *plugin_name, cons
508
}
509
510
void rrdpush_send_job_deleted(RRDHOST *host, const char *plugin_name, const char *module_name, const char *job_name) {
520
- dyncfg_check_can_push(host);
511
+ if(!dyncfg_can_push(host)) return;
512
513
BUFFER *wb = sender_start(host->sender);
514
@@ -622,7 +613,7 @@ void rrdpush_send_global_functions(RRDHOST *host) {
613
}
614
615
void rrdpush_send_dyncfg(RRDHOST *host) {
625
- dyncfg_check_can_push(host);
616
+ if(!dyncfg_can_push(host)) return;
617
618
BUFFER *wb = sender_start(host->sender);
619
@@ -654,9 +645,8 @@ void rrdpush_send_dyncfg(RRDHOST *host) {
645
sender_thread_buffer_free();
646
}
647
657
-void rrdpush_send_dyncfg_enable(RRDHOST *host, const char *plugin_name)
658
-{
659
- dyncfg_check_can_push(host);
648
+void rrdpush_send_dyncfg_enable(RRDHOST *host, const char *plugin_name) {
649
+ if(!dyncfg_can_push(host)) return;
650
651
BUFFER *wb = sender_start(host->sender);
652
@@ -667,9 +657,8 @@ void rrdpush_send_dyncfg_enable(RRDHOST *host, const char *plugin_name)
657
sender_thread_buffer_free();
658
}
659
670
-void rrdpush_send_dyncfg_reg_module(RRDHOST *host, const char *plugin_name, const char *module_name, enum module_type type)
671
-{
672
- dyncfg_check_can_push(host);
660
+void rrdpush_send_dyncfg_reg_module(RRDHOST *host, const char *plugin_name, const char *module_name, enum module_type type) {
661
+ if(!dyncfg_can_push(host)) return;
662
663
BUFFER *wb = sender_start(host->sender);
664
@@ -680,9 +669,8 @@ void rrdpush_send_dyncfg_reg_module(RRDHOST *host, const char *plugin_name, cons
669
sender_thread_buffer_free();
670
}
671
683
-void rrdpush_send_dyncfg_reg_job(RRDHOST *host, const char *plugin_name, const char *module_name, const char *job_name, enum job_type type, uint32_t flags)
684
-{
685
- dyncfg_check_can_push(host);
672
+void rrdpush_send_dyncfg_reg_job(RRDHOST *host, const char *plugin_name, const char *module_name, const char *job_name, enum job_type type, uint32_t flags) {
673
+ if(!dyncfg_can_push(host)) return;
674
675
BUFFER *wb = sender_start(host->sender);
676
@@ -693,9 +681,8 @@ void rrdpush_send_dyncfg_reg_job(RRDHOST *host, const char *plugin_name, const c
681
sender_thread_buffer_free();
682
}
683
696
-void rrdpush_send_dyncfg_reset(RRDHOST *host, const char *plugin_name)
697
-{
698
- dyncfg_check_can_push(host);
684
+void rrdpush_send_dyncfg_reset(RRDHOST *host, const char *plugin_name) {
685
+ if(!dyncfg_can_push(host)) return;
686
687
BUFFER *wb = sender_start(host->sender);
688
web/api/queries/query.c
+1
-1
@@ -1723,7 +1723,7 @@ static void rrd2rrdr_query_execute(RRDR *r, size_t dim_id_in_rrdr, QUERY_ENGINE_
1723
case TIER_QUERY_FETCH_SUM:
1724
new_point.value = sp.sum;
1725
break;
1726
- };
1726
+ }
1727
}
1728
}
1729
else
web/server/h2o/streaming.c
+4
-3
@@ -138,9 +138,10 @@ static void stream_on_recv(h2o_socket_t *sock, const char *err)
138
#define STREAM_METHOD "STREAM "
139
#define USER_AGENT "User-Agent: "
140
141
-#define NEED_MIN_BYTES(buf, bytes) \
142
-if (rbuf_bytes_available(buf) < bytes) \
143
- return GIMME_MORE_OF_DEM_SWEET_BYTEZ;
141
+#define NEED_MIN_BYTES(buf, bytes) do { \
142
+ if(rbuf_bytes_available(buf) < bytes) \
143
+ return GIMME_MORE_OF_DEM_SWEET_BYTEZ;\
144
+} while(0)
145
146
// TODO check in streaming code this is probably defined somewhere already
147
#define MAX_LEN_STREAM_HELLO (1024*2)