23 : query_(query), thread_(this_thread::get_id()) {
26 isc_throw(InvalidParameter,
"null query in ClientHandler");
29 isc_throw(InvalidParameter,
"null client-id in ClientHandler");
32 duid_ = client_id->getDuid();
35 mutex ClientHandler::mutex_;
37 ClientHandler::ClientContainer ClientHandler::clients_;
39 ClientHandler::ClientPtr
40 ClientHandler::lookup(
const DuidPtr& duid) {
43 isc_throw(InvalidParameter,
"null duid in ClientHandler::lookup");
46 auto it = clients_.find(duid->getDuid());
47 if (it == clients_.end()) {
54 ClientHandler::add(
const ClientPtr& client) {
57 isc_throw(InvalidParameter,
"null client in ClientHandler::add");
61 clients_.insert(client);
65 ClientHandler::del(
const DuidPtr& duid) {
68 isc_throw(InvalidParameter,
"null duid in ClientHandler::del");
72 clients_.erase(duid->getDuid());
80 lock_guard<mutex> lk(mutex_);
95 const DuidPtr& duid = query->getClientId();
100 if (duid->getDuid().empty()) {
107 client_.reset(
new Client(query, duid));
111 lock_guard<mutex> lk(mutex_);
112 holder = lookup(duid);
120 next_query = holder->next_query_;
121 holder->next_query_ = query;
122 holder->cont_ = cont;
131 .arg(next_query->toText())
132 .arg(this_thread::get_id())
133 .arg(holder->query_->toText())
134 .arg(holder->thread_);
136 static_cast<int64_t>(1));
142 .arg(query->toText())
143 .arg(this_thread::get_id())
144 .arg(holder->query_->toText())
145 .arg(holder->thread_);
147 static_cast<int64_t>(1));
153 ClientHandler::lock() {
163 ClientHandler::unLock() {
172 if (!client_ || !client_->cont_) {
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 int DBGLVL_PKT_HANDLING
This debug level is reserved for logging the details of packet handling, such as dropping the packet ...
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.
virtual ~ClientHandler()
Destructor.
bool getMode() const
Get the multi-threading mode.
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-lfc.
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.