summaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorNick Foster <nick@nerdnetworks.org>2010-10-01 16:08:37 -0700
committerNick Foster <nick@nerdnetworks.org>2010-10-01 16:08:37 -0700
commitbd3bd0dfbc1a87af5839c9b23450434cfb9c763c (patch)
tree6745a05ae81f48ebd3e0f9eb9493bb63835eb87b /host
parenta772f4536e46227df3301c637927c3fbfb69a08d (diff)
downloaduhd-bd3bd0dfbc1a87af5839c9b23450434cfb9c763c.tar.gz
uhd-bd3bd0dfbc1a87af5839c9b23450434cfb9c763c.tar.bz2
uhd-bd3bd0dfbc1a87af5839c9b23450434cfb9c763c.zip
UHD: added mutex to fix race condition in device enumeration.
Diffstat (limited to 'host')
-rw-r--r--host/lib/transport/libusb1_base.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/host/lib/transport/libusb1_base.cpp b/host/lib/transport/libusb1_base.cpp
index 910b04fc8..1dd0b48e8 100644
--- a/host/lib/transport/libusb1_base.cpp
+++ b/host/lib/transport/libusb1_base.cpp
@@ -35,7 +35,9 @@ public:
libusb_session_impl(void){
UHD_ASSERT_THROW(libusb_init(&_context) == 0);
libusb_set_debug(_context, debug_level);
+ _mutex.lock();
_thread_group.create_thread(boost::bind(&libusb_session_impl::run_event_loop, this));
+ _mutex.lock();
}
~libusb_session_impl(void){
@@ -52,11 +54,13 @@ private:
libusb_context *_context;
boost::thread_group _thread_group;
bool _running;
+ boost::mutex _mutex;
void run_event_loop(void){
set_thread_priority_safe();
_running = true;
timeval tv;
+ _mutex.unlock();
while(_running){
tv.tv_sec = 0;
tv.tv_usec = 100000; //100ms