Просмотр исходного кода

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 лет назад
Родитель
Сommit
bedb2eea3e
1 измененных файлов с 2 добавлено и 0 удалено
  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) {
 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);
     int ret = rrdvar_callback_for_all_host_variables(host, rrdpush_sender_thread_custom_host_variables_callback, host);
     (void)ret;
     (void)ret;
+    sender_commit(host->sender);
 
 
     debug(D_STREAM, "RRDVAR sent %d VARIABLES", ret);
     debug(D_STREAM, "RRDVAR sent %d VARIABLES", ret);
 }
 }