From: Jan Andres Date: Wed, 21 Oct 2015 11:50:43 +0000 (+0200) Subject: Start write threads after plugin initialization. X-Git-Tag: collectd-5.5.1~50^2~2 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=b888aac60926d5d31af6a87a2a86ba02da032ad3;p=collectd.git Start write threads after plugin initialization. Some plugins such as "network" create own threads from within their init callbacks which can then start submitting data to the queue right away, even if the read threads haven't been started yet. If write threads are started before plugin initialization, this can result in a race where a plugin's write callback gets called before that plugin's init callback has completed. To fix this, delay starting the write threads until after all plugins have been initialized. --- diff --git a/src/plugin.c b/src/plugin.c index 97352c47..6d3d3c95 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -1501,8 +1501,6 @@ void plugin_init_all (void) write_threads_num = 5; } - start_write_threads ((size_t) write_threads_num); - if ((list_init == NULL) && (read_heap == NULL)) return; @@ -1538,6 +1536,8 @@ void plugin_init_all (void) le = le->next; } + start_write_threads ((size_t) write_threads_num); + /* Start read-threads */ if (read_heap != NULL) {