Skip to content

Commit

Permalink
fix sender parsing when receiving remote input (netdata#17696)
Browse files Browse the repository at this point in the history
* fix sender parsing when receiving remote input

* moved obsolete statement
  • Loading branch information
ktsaou committed May 17, 2024
1 parent 4dbed7d commit f3e0205
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/streaming/sender.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit f3e0205

Please sign in to comment.