From 887d270a8327da46a89d8e5375f172db778f0ff9 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sat, 25 Mar 2017 18:21:12 +0100 Subject: Fix race condition for PipelinedModCodec thread startup The thread could start before the vtable containing the subclass function is ready, leading to a crash because the thread calls a pure virtual function. --- src/ModPlugin.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/ModPlugin.h') diff --git a/src/ModPlugin.h b/src/ModPlugin.h index f3a8e2a..d3aa780 100644 --- a/src/ModPlugin.h +++ b/src/ModPlugin.h @@ -83,15 +83,20 @@ public: virtual const char* name() = 0; protected: - void process_thread(void); + // Once the instance implementing PipelinedModCodec has been constructed, + // it must call start_pipeline_thread() + void start_pipeline_thread(void); virtual int internal_process(Buffer* const dataIn, Buffer* dataOut) = 0; +private: + size_t m_number_of_runs; + ThreadsafeQueue > m_input_queue; ThreadsafeQueue > m_output_queue; std::atomic m_running; - size_t m_number_of_runs; std::thread m_thread; + void process_thread(void); }; -- cgit v1.2.3