summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@netdata.cloud>2024-05-17 18:54:20 +0300
committerGitHub <noreply@github.com>2024-05-17 18:54:20 +0300
commitf3e0205be0243d8055b8e7da9dd2fe073f2e213d (patch)
tree5cd8039d6f20e4cee8d4b9e35be2d4a2d6dac173
parent4dbed7d6b590174ac9433b7a621649fb9fb21544 (diff)
fix sender parsing when receiving remote input (#17696)
* fix sender parsing when receiving remote input * moved obsolete statement
-rw-r--r--src/streaming/sender.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/streaming/sender.c b/src/streaming/sender.c
index 84b5566376..0ae66db6b6 100644
--- a/src/streaming/sender.c
+++ b/src/streaming/sender.c
@@ -1232,12 +1232,23 @@ void execute_commands(struct sender_state *s) {
ND_LOG_STACK_PUSH(lgs);
char *start = s->read_buffer, *end = &s->read_buffer[s->read_len], *newline;
- *end = 0;
- while( start < end && (newline = strchr(start, '\n')) ) {
+ *end = '\0';
+ for( ; start < end ; start = newline + 1) {
+ newline = strchr(start, '\n');
+
+ if(!newline) {
+ if(s->functions.intercept_input) {
+ buffer_strcat(s->functions.payload, start);
+ start = end;
+ }
+ break;
+ }
+
+ *newline = '\0';
s->line.count++;
if(s->functions.intercept_input) {
- if(strcmp(start, PLUGINSD_CALL_FUNCTION_PAYLOAD_END "\n") == 0) {
+ if(strcmp(start, PLUGINSD_CALL_FUNCTION_PAYLOAD_END) == 0) {
execute_commands_function(s,
PLUGINSD_CALL_FUNCTION_PAYLOAD_END,
s->functions.transaction, s->functions.timeout_s,
@@ -1246,14 +1257,14 @@ void execute_commands(struct sender_state *s) {
cleanup_intercepting_input(s);
}
- else
+ else {
buffer_strcat(s->functions.payload, start);
+ buffer_fast_charcat(s->functions.payload, '\n');
+ }
- start = newline + 1;
continue;
}
- *newline = '\0';
s->line.num_words = quoted_strings_splitter_pluginsd(start, s->line.words, PLUGINSD_MAX_WORDS);
const char *command = get_word(s->line.words, s->line.num_words, 0);
@@ -1332,7 +1343,6 @@ void execute_commands(struct sender_state *s) {
line_splitter_reset(&s->line);
worker_is_busy(WORKER_SENDER_JOB_EXECUTE);
- start = newline + 1;
}
if (start < end) {