namespace isc {
namespace dhcp {
-mutex ClientHandler::mutex_client_id_;
-
-mutex ClientHandler::mutex_hwaddr_;
+mutex ClientHandler::mutex_;
ClientHandler::ClientByIdContainer ClientHandler::clients_client_id_;
}
ClientHandler::~ClientHandler() {
+ lock_guard<mutex> lock_(mutex_);
if (locked_client_id_) {
- lock_guard<mutex> lock_(mutex_client_id_);
unLockById();
}
locked_client_id_.reset();
if (locked_hwaddr_) {
- lock_guard<mutex> lock_(mutex_hwaddr_);
unLockByHWAddr();
}
locked_hwaddr_.reset();
if (duid) {
// Try to acquire the by-client-id lock and return the holder
// when it failed.
- lock_guard<mutex> lock_(mutex_client_id_);
+ lock_guard<mutex> lock_(mutex_);
holder_id = lookup(duid);
if (!holder_id) {
locked_client_id_ = duid;
}
// Try to acquire the by-hw-addr lock and return the holder
// when it failed.
- lock_guard<mutex> lock_(mutex_hwaddr_);
+ lock_guard<mutex> lock_(mutex_);
holder_hw = lookup(hwaddr);
if (!holder_hw) {
locked_hwaddr_ = hwaddr;
/// @brief Hardware address locked by this handler.
HWAddrPtr locked_hwaddr_;
- /// @brief Mutex to protect the client-by-id container.
- static std::mutex mutex_client_id_;
-
- /// @brief Mutex to protect the client-by-hwaddr container.
- static std::mutex mutex_hwaddr_;
+ /// @brief Mutex to protect client containers.
+ static std::mutex mutex_;
/// @brief Lookup a client-by-id.
///
- /// The by-id mutex must be held by the caller.
+ /// The mutex must be held by the caller.
///
/// @param duid The duid of the query from the client.
/// @return The held client or null.
/// @brief Lookup a client-by-hwaddr.
///
- /// The by-hwaddr mutex must be held by the caller.
+ /// The mutex must be held by the caller.
///
/// @param duid The duid of the query from the client.
/// @return The held client or null.
/// @brief Acquire a client by client ID option.
///
- /// The by-id mutex must be held by the caller.
+ /// The mutex must be held by the caller.
void lockById();
/// @brief Acquire a client by hardware address.
///
- /// The by-hwaddr mutex must be held by the caller.
+ /// The mutex must be held by the caller.
void lockByHWAddr();
/// @brief Release a client by client ID option.
///
- /// The by-idmutex must be held by the caller.
+ /// The mutex must be held by the caller.
void unLockById();
/// @brief Release a client by hardware address.
///
- /// The by-hwaddr mutex must be held by the caller.
+ /// The mutex must be held by the caller.
void unLockByHWAddr();
/// @brief The type of the client-by-id container.