Commit a09bee9b authored by Razvan Becheriu's avatar Razvan Becheriu

[#889,!591] lock only in MT mode

parent 1b27c56f
......@@ -19,6 +19,7 @@
#include <dhcp/docsis3_option_defs.h>
#include <exceptions/exceptions.h>
#include <util/buffer.h>
#include <util/multi_threading_mgr.h>
#include <boost/lexical_cast.hpp>
#include <boost/shared_array.hpp>
......@@ -89,7 +90,16 @@ void initOptionSpace(OptionDefContainerPtr& defs,
const OptionDefContainerPtr&
LibDHCP::getOptionDefs(const std::string& space) {
static mutex local_mutex;
if (MultiThreadingMgr::instance().getMode()) {
std::lock_guard<std::mutex> lock(local_mutex);
return LibDHCP::getOptionDefs(space);
} else {
return LibDHCP::getOptionDefs(space);
const OptionDefContainerPtr&
LibDHCP::getOptionDefsInternal(const std::string& space) {
// If any of the containers is not initialized, it means that we haven't
// initialized option definitions at all.
if (option_defs_.end() == option_defs_.find(space)) {
......@@ -366,6 +366,16 @@ public:
static uint32_t optionSpaceToVendorId(const std::string& option_space);
/// @brief Returns collection of option definitions.
/// This method returns a collection of option definitions for a specified
/// option space. It must be called in a thread safe scope when MT is enabled.
/// @param space Option space.
/// @return Pointer to a collection of option definitions.
static const OptionDefContainerPtr& getOptionDefsInternal(const std::string& space);
/// Initialize DHCP option definitions.
/// The method creates option definitions for all DHCP options.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment