summaryrefslogtreecommitdiffstats
path: root/collectors/plugins.d
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@netdata.cloud>2023-09-08 11:32:11 +0300
committerGitHub <noreply@github.com>2023-09-08 11:32:11 +0300
commit31924c0eb2fb245bdf047a5f4fe9f5ef10baf24e (patch)
treee1283dfc821a1eea2f5f45a5b1f12bde4d87e368 /collectors/plugins.d
parent43b1a2e25ed1275ccd60e6c2c7eed550ee44adf7 (diff)
systemd-journal and facets improvements (#15926)
Diffstat (limited to 'collectors/plugins.d')
-rw-r--r--collectors/plugins.d/plugins_d.h2
-rw-r--r--collectors/plugins.d/pluginsd_parser.h9
2 files changed, 7 insertions, 4 deletions
diff --git a/collectors/plugins.d/plugins_d.h b/collectors/plugins.d/plugins_d.h
index 4988b50719..135f30eca4 100644
--- a/collectors/plugins.d/plugins_d.h
+++ b/collectors/plugins.d/plugins_d.h
@@ -123,7 +123,7 @@ size_t pluginsd_initialize_plugin_directories();
#define pluginsd_function_result_end_to_stdout() \
fprintf(stdout, "\n" PLUGINSD_KEYWORD_FUNCTION_RESULT_END "\n")
-static inline void pluginsd_function_json_error(const char *transaction, int code, const char *msg) {
+static inline void pluginsd_function_json_error_to_stdout(const char *transaction, int code, const char *msg) {
char buffer[PLUGINSD_LINE_MAX + 1];
json_escape_string(buffer, msg, PLUGINSD_LINE_MAX);
diff --git a/collectors/plugins.d/pluginsd_parser.h b/collectors/plugins.d/pluginsd_parser.h
index 8635059d92..9fdb5846dd 100644
--- a/collectors/plugins.d/pluginsd_parser.h
+++ b/collectors/plugins.d/pluginsd_parser.h
@@ -10,6 +10,9 @@
// this has to be in-sync with the same at receiver.c
#define WORKER_RECEIVER_JOB_REPLICATION_COMPLETION (WORKER_PARSER_FIRST_JOB - 3)
+// this controls the max response size of a function
+#define PLUGINSD_MAX_DEFERRED_SIZE (20 * 1024 * 1024)
+
// PARSER return codes
typedef enum __attribute__ ((__packed__)) parser_rc {
PARSER_RC_OK, // Callback was successful, go on
@@ -157,9 +160,9 @@ static inline int parser_action(PARSER *parser, char *input) {
if(!has_keyword || strcmp(command, parser->defer.end_keyword) != 0) {
if(parser->defer.response) {
buffer_strcat(parser->defer.response, input);
- if(buffer_strlen(parser->defer.response) > 10 * 1024 * 1024) {
- // more than 10MB of data
- // a bad plugin that did not send the end_keyword
+ if(buffer_strlen(parser->defer.response) > PLUGINSD_MAX_DEFERRED_SIZE) {
+ // more than PLUGINSD_MAX_DEFERRED_SIZE of data,
+ // or a bad plugin that did not send the end_keyword
internal_error(true, "PLUGINSD: deferred response is too big (%zu bytes). Stopping this plugin.", buffer_strlen(parser->defer.response));
return 1;
}