From 4335003e2e7d704f5f1d229b6a08cdb97088f785 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 26 Apr 2011 12:04:07 -0700 Subject: uhd: added scoped lock to device find and make (for thread safety) --- host/lib/device.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'host/lib') diff --git a/host/lib/device.cpp b/host/lib/device.cpp index 1b3daa103..b2b0238d2 100644 --- a/host/lib/device.cpp +++ b/host/lib/device.cpp @@ -25,10 +25,13 @@ #include #include #include +#include #include using namespace uhd; +static boost::mutex _device_mutex; + /*********************************************************************** * Helper Functions **********************************************************************/ @@ -70,6 +73,8 @@ void device::register_device( * Discover **********************************************************************/ device_addrs_t device::find(const device_addr_t &hint){ + boost::mutex::scoped_lock lock(_device_mutex); + device_addrs_t device_addrs; BOOST_FOREACH(const dev_fcn_reg_t &fcn, get_dev_fcn_regs()){ @@ -93,6 +98,8 @@ device_addrs_t device::find(const device_addr_t &hint){ * Make **********************************************************************/ device::sptr device::make(const device_addr_t &hint, size_t which){ + boost::mutex::scoped_lock lock(_device_mutex); + typedef boost::tuple dev_addr_make_t; std::vector dev_addr_makers; -- cgit v1.2.3