diff options
author | Jiří Pinkava <j-pi@seznam.cz> | 2015-03-17 23:32:35 +0100 |
---|---|---|
committer | Jiří Pinkava <j-pi@seznam.cz> | 2015-04-01 14:35:05 +0200 |
commit | 2aded1af5e55dca76c0b9cd4476b083b8fd8d3f7 (patch) | |
tree | d2c51ac5e0b09723c0aebe581e5734d0ae48b64f /gnuradio-runtime/lib/top_block_impl.h | |
parent | d817c5fd35dd71d5e4591f04d39e565935215ae9 (diff) |
runtime: fix wait() race condition
Func. wait() should wait until all work is completed, but should not
exit when block is locked()/unlocked() for flow-graph reconfiguration.
It is unprobable, but during unlock() thread context might be switched
after stop() is called but before new thread are executed by scheduller.
This can cause exit from wait() when it is called (eg. from Python
wrapper).
Call of stop() is moved into lock(), no new work should be started on
locked block and this gives threads some time to finish before join()
is called from unlock().
Diffstat (limited to 'gnuradio-runtime/lib/top_block_impl.h')
-rw-r--r-- | gnuradio-runtime/lib/top_block_impl.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/gnuradio-runtime/lib/top_block_impl.h b/gnuradio-runtime/lib/top_block_impl.h index 67395e0c35..1ac5136ddf 100644 --- a/gnuradio-runtime/lib/top_block_impl.h +++ b/gnuradio-runtime/lib/top_block_impl.h @@ -82,10 +82,12 @@ namespace gr { gr::thread::mutex d_mutex; // protects d_state and d_lock_count tb_state d_state; int d_lock_count; + boost::condition_variable d_lock_cond; int d_max_noutput_items; private: void restart(); + void wait_for_jobs(); }; } /* namespace gr */ |