Browse Source

Fixed concurrency bug in health sending HOST VARIABLE to receiver (#9396)

The recent changes to the streaming component wipe the send buffer when the mutex is acquired to prevent stale data and expose concurrency bugs. The callback from health was called from another thread to write into the stream buffer without any protection. This protects the access to the buffer.
thiagoftsm 4 years ago
parent
commit
bedb2eea3e
1 changed files with 2 additions and 0 deletions
  1. 2 0
      streaming/sender.c

+ 2 - 0
streaming/sender.c

@@ -70,8 +70,10 @@ static int rrdpush_sender_thread_custom_host_variables_callback(void *rrdvar_ptr
 }
 
 static void rrdpush_sender_thread_send_custom_host_variables(RRDHOST *host) {
+    sender_start(host->sender);
     int ret = rrdvar_callback_for_all_host_variables(host, rrdpush_sender_thread_custom_host_variables_callback, host);
     (void)ret;
+    sender_commit(host->sender);
 
     debug(D_STREAM, "RRDVAR sent %d VARIABLES", ret);
 }