summaryrefslogtreecommitdiffstats
path: root/libnetdata/string
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@netdata.cloud>2024-01-11 16:56:45 +0200
committerGitHub <noreply@github.com>2024-01-11 16:56:45 +0200
commitf2b250a1f53af00241522db35f8c85f19ed282e1 (patch)
treee813ca47880e3e2adf09583658efef59633ec6bd /libnetdata/string
parentbead543ea52e51cf73f7e5b27de53197801399a7 (diff)
dyncfg v2 (#16702)
* split rrdfunctions streaming and progress * simplified internal inline functions API * split rrdfunctions inflight management * split rrd functions exporters * renames * base dyncfg structure * config pluginsd * intercept dyncfg function calls * loading and saving of dyncfg metadata and data * save metadata and payload to a single file; added code to update the plugins with jobs and saved configs * basic working unit test * added payload to functions execution * removed old dyncfg code that is not needed any more * more cleanup * cleanup sender for functions with payload * dyncfg functions are not exposed as functions * remaining work to avoid indexing the \0 terminating character in dictionary keys * added back old dyncfg plugins.d commands as noop, to allow plugins continue working * working api; working streaming; * updated plugins.d documentation * aclk and http api requests share the same header parsing logic * added source type internal * fixed crashes * added god mode for tests * fixes * fixed messages * save host machine guids to configs * cleaner manipulation of supported commands * the functions event loop for external plugins can now process dyncfg requests * unified internal and external plugins dyncfg API * Netdata serves schema requests from /etc/netdata/schema.d and /var/lib/netdata/conf.d/schema.d * cleanup and various fixes; fixed bug in previous dyncfg implementation on streaming that was sending the paylod in a way that allowed other streaming commands to be multiplexed * internals go to a separate header file * fix duplicate ACLK requests sent by aclk queue mechanism * use fstat instead of stat * working api * plugin actions renamed to create and delete; dyncfg files are removed only from user actions * prevent deadlock by using the react callback * fix for string_strndupz() * better dyncfg unittests * more tests at the unittests * properly detect dyncfg functions * hide config functions from the UI * tree response improvements * send the initial update with payload * determine tty using stdout, not stderr * changes to statuses, cleanup and the code to bring all business logic into interception * do not crash when the status is empty * functions now propagate the source of the requests to plugins * avoid warning about unused functions * in the count at items for attention, do not count the orphan entries * save source into dyncfg * make the list null terminated * fixed invalid comparison * prevent memory leak on duplicated headers; log x-forwarded-for * more unit tests * added dyncfg unittests into the default unittests * more unit tests and fixes * more unit tests and fixes * fix dictionary unittests * config functions require admin access
Diffstat (limited to 'libnetdata/string')
-rw-r--r--libnetdata/string/string.c19
-rw-r--r--libnetdata/string/string.h3
2 files changed, 22 insertions, 0 deletions
diff --git a/libnetdata/string/string.c b/libnetdata/string/string.c
index 81c8b3401f..0b4a6470d7 100644
--- a/libnetdata/string/string.c
+++ b/libnetdata/string/string.c
@@ -307,6 +307,25 @@ STRING *string_strdupz(const char *str) {
return string;
}
+STRING *string_strndupz(const char *str, size_t len) {
+ if(unlikely(!str || !*str || !len)) return NULL;
+
+#ifdef NETDATA_INTERNAL_CHECKS
+ uint8_t partition = string_partition_str(str);
+#endif
+
+ char buf[len + 1];
+ memcpy(buf, str, len);
+ buf[len] = '\0';
+
+ STRING *string = string_index_search(buf, len + 1);
+ while(!string)
+ string = string_index_insert(buf, len + 1);
+
+ string_stats_atomic_increment(partition, active_references);
+ return string;
+}
+
void string_freez(STRING *string) {
if(unlikely(!string)) return;
diff --git a/libnetdata/string/string.h b/libnetdata/string/string.h
index ba0e3876bc..f2ff9666ca 100644
--- a/libnetdata/string/string.h
+++ b/libnetdata/string/string.h
@@ -8,7 +8,10 @@
// STRING implementation
typedef struct netdata_string STRING;
+
STRING *string_strdupz(const char *str);
+STRING *string_strndupz(const char *str, size_t len);
+
STRING *string_dup(STRING *string);
void string_freez(STRING *string);
size_t string_strlen(STRING *string);