// SPDX-License-Identifier: GPL-3.0-or-later#include"rrdpush.h"#include"parser/parser.h"#define WORKER_SENDER_JOB_CONNECT 0#define WORKER_SENDER_JOB_PIPE_READ 1#define WORKER_SENDER_JOB_SOCKET_RECEIVE 2#define WORKER_SENDER_JOB_EXECUTE 3#define WORKER_SENDER_JOB_SOCKET_SEND 4#define WORKER_SENDER_JOB_DISCONNECT_BAD_HANDSHAKE 5#define WORKER_SENDER_JOB_DISCONNECT_OVERFLOW 6#define WORKER_SENDER_JOB_DISCONNECT_TIMEOUT 7#define WORKER_SENDER_JOB_DISCONNECT_POLL_ERROR 8#define WORKER_SENDER_JOB_DISCONNECT_SOCKER_ERROR 9#define WORKER_SENDER_JOB_DISCONNECT_SSL_ERROR 10#define WORKER_SENDER_JOB_DISCONNECT_PARENT_CLOSED 11#define WORKER_SENDER_JOB_DISCONNECT_RECEIVE_ERROR 12#define WORKER_SENDER_JOB_DISCONNECT_SEND_ERROR 13#define WORKER_SENDER_JOB_DISCONNECT_NO_COMPRESSION 14#define WORKER_SENDER_JOB_BUFFER_RATIO 15#define WORKER_SENDER_JOB_BYTES_RECEIVED 16#define WORKER_SENDER_JOB_BYTES_SENT 17#if WORKER_UTILIZATION_MAX_JOB_TYPES < 18#error WORKER_UTILIZATION_MAX_JOB_TYPES has to be at least 18#endifexternstructconfigstream_config;externintnetdata_use_ssl_on_stream;externchar*netdata_ssl_ca_path;externchar*netdata_ssl_ca_file;static__threadBUFFER*sender_thread_buffer=NULL;static__threadboolsender_thread_buffer_used=false;voidsender_thread_buffer_free(void){if(sender_thread_buffer){buffer_free(sender_thread_buffer);sender_thread_buffer=NULL;}}// Collector thread starting a transmissionBUFFER*sender_start(structsender_state*s__maybe_unused){if(!sender_thread_buffer)sender_thread_buffer=buffer_create(1024);if(sender_thread_buffer_used)fatal("STREAMING: thread buffer is used multiple times concurrently.");sender_thread_buffer_used=true;buffer_flush(sender_thread_buffer);returnsender_thread_buffer;}voidsender_cancel(structsender_state*s__maybe_unused){sender_thread_buffer_used=false;}staticinlinevoidrrdpush_sender_thread_close_socket(RRDHOST*host);#ifdef ENABLE_COMPRESSION/** In case of stream compression buffer oveflow* Inform the user through the error log file and * deactivate compression by downgrading the stream protocol.*/staticinlinevoiddeactivate_compression(struct