22 : query_(query), thread_(this_thread::get_id()) {
25 isc_throw(InvalidParameter,
"null query in ClientHandler");
28 isc_throw(InvalidParameter,
"null client-id in ClientHandler");
31 duid_ = client_id->getDuid();
34 mutex ClientHandler::mutex_;
36 ClientHandler::ClientContainer ClientHandler::clients_;
38 ClientHandler::ClientPtr
39 ClientHandler::lookup(
const DuidPtr& duid) {
42 isc_throw(InvalidParameter,
"null duid in ClientHandler::lookup");
45 auto it = clients_.find(duid->getDuid());
46 if (it == clients_.end()) {
53 ClientHandler::add(
const ClientPtr& client) {
56 isc_throw(InvalidParameter,
"null client in ClientHandler::add");
60 clients_.insert(client);
64 ClientHandler::del(
const DuidPtr& duid) {
67 isc_throw(InvalidParameter,
"null duid in ClientHandler::del");
71 clients_.erase(duid->getDuid());
79 lock_guard<mutex> lk(mutex_);
94 const DuidPtr& duid = query->getClientId();
99 if (duid->getDuid().empty()) {
106 client_.reset(
new Client(query, duid));
110 lock_guard<mutex> lk(mutex_);
111 holder = lookup(duid);
119 next_query = holder->next_query_;
120 holder->next_query_ = query;
121 holder->cont_ = cont;
130 .arg(next_query->toText())
131 .arg(this_thread::get_id())
132 .arg(holder->query_->toText())
133 .arg(holder->thread_);
135 static_cast<int64_t>(1));
141 .arg(query->toText())
142 .arg(this_thread::get_id())
143 .arg(holder->query_->toText())
144 .arg(holder->thread_);
146 static_cast<int64_t>(1));
152 ClientHandler::lock() {
162 ClientHandler::unLock() {
165 isc_throw(Unexpected,
"nothing to unlock in ClientHandler::unLock");
171 if (!client_ || !client_->cont_) {
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
boost::shared_ptr< DUID > DuidPtr
const isc::log::MessageID DHCP6_PACKET_DROP_DUPLICATE
A generic exception that is thrown if a parameter given to a method or function is considered invalid...
const int DBG_DHCP6_BASIC
Debug level used to trace basic operations within the code.
const isc::log::MessageID DHCP6_PACKET_QUEUE_FULL
static StatsMgr & instance()
Statistics Manager accessor method.
bool addFront(const WorkItemPtr &item)
add a work item to the thread pool at front
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
ClientHandler()
Public interface.
A generic exception that is thrown when an unexpected error condition occurs.
bool getMode() const
Get the multi-threading mode.
virtual ~ClientHandler()
Destructor.
void addValue(const std::string &name, const int64_t value)
Records incremental integer observation.
Defines the logger used by the top-level component of kea-dhcp-ddns.
ThreadPool< std::function< void()> > & getThreadPool()
Get the dhcp thread pool.
bool tryLock(Pkt4Ptr query, ContinuationPtr cont=ContinuationPtr())
Tries to acquires a client.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
isc::log::Logger bad_packet6_logger(DHCP6_BAD_PACKET_LOGGER_NAME)
Logger for rejected packets.
boost::shared_ptr< Continuation > ContinuationPtr
Define the type of shared pointers to continuations.
isc::log::Logger dhcp6_logger(DHCP6_APP_LOGGER_NAME)
Base logger for DHCPv6 server.