summaryrefslogtreecommitdiffstats
path: root/libnetdata
diff options
context:
space:
mode:
authorvkalintiris <vasilis@netdata.cloud>2022-01-18 10:30:36 +0200
committerGitHub <noreply@github.com>2022-01-18 10:30:36 +0200
commite91d1110e5998ede7bc8aecf5309c28176361acf (patch)
treeb785a25971d62a4cd360d24a66679a0f389d6b5d /libnetdata
parent63afbd76ef39ca836233354218e95a17ae67270e (diff)
Do not use dbengine headers when dbengine is disabled. (#11967)
Prior to this commit both daemon/commands.c and spawn/spawn.c used to include database/engine/rrdenginelib.h, ie. a header file that is available only when enabling the dbengine feature.
Diffstat (limited to 'libnetdata')
-rw-r--r--libnetdata/Makefile.am1
-rw-r--r--libnetdata/completion/Makefile.am4
-rw-r--r--libnetdata/completion/completion.c34
-rw-r--r--libnetdata/completion/completion.h22
-rw-r--r--libnetdata/libnetdata.h6
5 files changed, 67 insertions, 0 deletions
diff --git a/libnetdata/Makefile.am b/libnetdata/Makefile.am
index 598b72f5b0..e787801c28 100644
--- a/libnetdata/Makefile.am
+++ b/libnetdata/Makefile.am
@@ -8,6 +8,7 @@ SUBDIRS = \
avl \
buffer \
clocks \
+ completion \
config \
dictionary \
ebpf \
diff --git a/libnetdata/completion/Makefile.am b/libnetdata/completion/Makefile.am
new file mode 100644
index 0000000000..babdcf0df3
--- /dev/null
+++ b/libnetdata/completion/Makefile.am
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+AUTOMAKE_OPTIONS = subdir-objects
+MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
diff --git a/libnetdata/completion/completion.c b/libnetdata/completion/completion.c
new file mode 100644
index 0000000000..77818f40d6
--- /dev/null
+++ b/libnetdata/completion/completion.c
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#include "completion.h"
+
+void completion_init(struct completion *p)
+{
+ p->completed = 0;
+ fatal_assert(0 == uv_cond_init(&p->cond));
+ fatal_assert(0 == uv_mutex_init(&p->mutex));
+}
+
+void completion_destroy(struct completion *p)
+{
+ uv_cond_destroy(&p->cond);
+ uv_mutex_destroy(&p->mutex);
+}
+
+void completion_wait_for(struct completion *p)
+{
+ uv_mutex_lock(&p->mutex);
+ while (0 == p->completed) {
+ uv_cond_wait(&p->cond, &p->mutex);
+ }
+ fatal_assert(1 == p->completed);
+ uv_mutex_unlock(&p->mutex);
+}
+
+void completion_mark_complete(struct completion *p)
+{
+ uv_mutex_lock(&p->mutex);
+ p->completed = 1;
+ uv_mutex_unlock(&p->mutex);
+ uv_cond_broadcast(&p->cond);
+}
diff --git a/libnetdata/completion/completion.h b/libnetdata/completion/completion.h
new file mode 100644
index 0000000000..667360a424
--- /dev/null
+++ b/libnetdata/completion/completion.h
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#ifndef NETDATA_COMPLETION_H
+#define NETDATA_COMPLETION_H
+
+#include "../libnetdata.h"
+
+struct completion {
+ uv_mutex_t mutex;
+ uv_cond_t cond;
+ volatile unsigned completed;
+};
+
+void completion_init(struct completion *p);
+
+void completion_destroy(struct completion *p);
+
+void completion_wait_for(struct completion *p);
+
+void completion_mark_complete(struct completion *p);
+
+#endif /* NETDATA_COMPLETION_H */
diff --git a/libnetdata/libnetdata.h b/libnetdata/libnetdata.h
index b49ab21a08..432c74f461 100644
--- a/libnetdata/libnetdata.h
+++ b/libnetdata/libnetdata.h
@@ -303,9 +303,14 @@ extern char *find_and_replace(const char *src, const char *find, const char *rep
#define KILOBITS_IN_A_MEGABIT 1000
/* misc. */
+
#define UNUSED(x) (void)(x)
#define error_report(x, args...) do { errno = 0; error(x, ##args); } while(0)
+// Taken from linux kernel
+#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
+
+
extern void netdata_cleanup_and_exit(int ret) NORETURN;
extern void send_statistics(const char *action, const char *action_result, const char *action_data);
extern char *netdata_configured_host_prefix;
@@ -318,6 +323,7 @@ extern char *netdata_configured_host_prefix;
#include "avl/avl.h"
#include "inlined.h"
#include "clocks/clocks.h"
+#include "completion/completion.h"
#include "popen/popen.h"
#include "simple_pattern/simple_pattern.h"
#ifdef ENABLE_HTTPS