From ca5dadab93d43607626467ce2f050a9b2732a462 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Wed, 27 Apr 2016 10:13:50 -0700 Subject: [PATCH] Set CaptureThread::thread to null after thread is released. Was having a timing problem where ISR was still trying to signal thread after thread was nulled. --- firmware/application/capture_thread.hpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/firmware/application/capture_thread.hpp b/firmware/application/capture_thread.hpp index d3b6841b..b48cb1ec 100644 --- a/firmware/application/capture_thread.hpp +++ b/firmware/application/capture_thread.hpp @@ -85,13 +85,11 @@ public: } ~CaptureThread() { - const auto thread_tmp = thread; - - if( thread_tmp ) { + if( thread ) { + chThdTerminate(thread); + chEvtSignal(thread, EVT_MASK_CAPTURE_THREAD); + const auto success = chThdWait(thread); thread = nullptr; - chThdTerminate(thread_tmp); - chEvtSignal(thread_tmp, EVT_MASK_CAPTURE_THREAD); - const auto success = chThdWait(thread_tmp); if( !success ) { led_tx.on();