From b888aac60926d5d31af6a87a2a86ba02da032ad3 Mon Sep 17 00:00:00 2001 From: Jan Andres Date: Wed, 21 Oct 2015 13:50:43 +0200 Subject: [PATCH] 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. --- src/plugin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) { -- 2.30.2