From b6f50e7f108614f57c6a934a40929470465564d1 Mon Sep 17 00:00:00 2001 From: Patrick Sisterhen Date: Thu, 12 Dec 2019 23:34:12 -0600 Subject: uhd: fix for exception due to use of unconstructed mutex In chdr_ctrl_endpoint recv_thread, _recv_thread was starting at construction time and trying to lock mutex, but due to member declaration in class, mutex was not yet constructed --- host/lib/rfnoc/chdr_ctrl_endpoint.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'host/lib/rfnoc/chdr_ctrl_endpoint.cpp') diff --git a/host/lib/rfnoc/chdr_ctrl_endpoint.cpp b/host/lib/rfnoc/chdr_ctrl_endpoint.cpp index d337dec5e..bba972186 100644 --- a/host/lib/rfnoc/chdr_ctrl_endpoint.cpp +++ b/host/lib/rfnoc/chdr_ctrl_endpoint.cpp @@ -31,7 +31,6 @@ public: sep_id_t my_epid) : _my_epid(my_epid) , _xport(xport) - , _send_seqnum(0) , _send_pkt(pkt_factory.make_ctrl()) , _recv_pkt(pkt_factory.make_ctrl()) , _stop_recv_thread(false) @@ -177,13 +176,15 @@ private: chdr_ctrl_packet::cuptr _recv_pkt; // A collection of ctrlport endpoints (keyed by the port number) std::map _endpoint_map; - // A thread that will handle all responses and async message requests - std::atomic_bool _stop_recv_thread; - std::thread _recv_thread; // Mutex that protects all state in this class except for _send_pkt std::mutex _mutex; // Mutex that protects _send_pkt and _xport.send std::mutex _send_mutex; + // A thread that will handle all responses and async message requests + // Must be declared after the mutexes, the thread starts at construction and + // depends on the mutexes having been constructed. + std::atomic_bool _stop_recv_thread; + std::thread _recv_thread; }; chdr_ctrl_endpoint::uptr chdr_ctrl_endpoint::make(chdr_ctrl_xport::sptr xport, -- cgit v1.2.3