void
ControlledDhcpv4Srv::init(const std::string& file_name) {
// Configure the server using JSON file.
- ConstElementPtr result;
- {
- LockGuard<mutex> lock(serverLock());
- result = loadConfigFile(file_name);
- }
+ ConstElementPtr result = loadConfigFile(file_name);
int rcode;
ConstElementPtr comment = isc::config::parseAnswer(rcode, result);
}
if (srv->run_multithreaded_) {
- {
- ReverseLock<std::mutex> rlk(srv->serverLock());
- srv->pkt_thread_pool_.destroy();
- }
+ srv->pkt_thread_pool_.destroy();
srv->pkt_thread_pool_.create(Dhcpv4Srv::threadCount());
}
// is no need to rollback configuration if socket fails to open on any
// of the interfaces.
CfgMgr::instance().getStagingCfg()->getCfgIface()->
- openSockets(AF_INET, srv->getServerPort(), srv->serverLock(),
+ openSockets(AF_INET, srv->getServerPort(),
getInstance()->useBroadcast());
// Install the timers for handling leases reclamation.
while (!shutdown_) {
try {
run_one();
- {
- LockGuard<mutex> lock(serverLock());
- getIOService()->poll();
- }
+ getIOService()->poll();
} catch (const std::exception& e) {
// General catch-all exception that are not caught by more specific
// catches. This one is for exceptions derived from std::exception.
// because it is important that the select() returns control
// frequently so as the IOService can be polled for ready handlers.
uint32_t timeout = 1;
- {
- // LOG_DEBUG(packet4_logger, DBG_DHCP4_DETAIL, DHCP4_BUFFER_WAIT).arg(timeout);
- LockGuard<mutex> lock(serverLock());
- query = receivePacket(timeout);
- }
+ // LOG_DEBUG(packet4_logger, DBG_DHCP4_DETAIL, DHCP4_BUFFER_WAIT).arg(timeout);
+ query = receivePacket(timeout);
// Log if packet has arrived. We can't log the detailed information
// about the DHCP message because it hasn't been unpacked/parsed
// receivePacket the process could wait up to the duration of timeout
// of select() to terminate.
try {
- LockGuard<mutex> lock(serverLock());
handleSignal();
} catch (const std::exception& e) {
// Standard exception occurred. Let's be on the safe side to
void
Dhcpv4Srv::processPacketAndSendResponse(Pkt4Ptr& query, Pkt4Ptr& rsp) {
- LockGuard<mutex> lock(serverLock());
processPacket(query, rsp);
if (!rsp) {
return;
/// @brief returns Kea DHCPv4 server max thread queue size.
static uint32_t maxThreadQueueSize();
- /// @brief returns Kea DHCPv4 server mutex.
- std::mutex* serverLock() {
- return mutex_.get();
- }
-
/// @brief Main server processing loop.
///
/// Main server processing loop. Call the processing step routine
void
ControlledDhcpv6Srv::init(const std::string& file_name) {
// Configure the server using JSON file.
- ConstElementPtr result;
- {
- LockGuard<mutex> lock(serverLock());
- result = loadConfigFile(file_name);
- }
+ ConstElementPtr result = loadConfigFile(file_name);
int rcode;
ConstElementPtr comment = isc::config::parseAnswer(rcode, result);
}
if (srv->run_multithreaded_) {
- {
- ReverseLock<std::mutex> rlk(srv->serverLock());
- srv->pkt_thread_pool_.destroy();
- }
+ srv->pkt_thread_pool_.destroy();
srv->pkt_thread_pool_.create(Dhcpv6Srv::threadCount());
}
// Regenerate server identifier if needed.
try {
- const std::string duid_file = CfgMgr::instance().getDataDir() + "/" +
+ const std::string duid_file =
+ std::string(CfgMgr::instance().getDataDir()) + "/" +
std::string(SERVER_DUID_FILE);
DuidPtr duid = CfgMgr::instance().getStagingCfg()->getCfgDUID()->create(duid_file);
server_->serverid_.reset(new Option(Option::V6, D6O_SERVERID, duid->getDuid()));
// is no need to rollback configuration if socket fails to open on any
// of the interfaces.
CfgMgr::instance().getStagingCfg()->getCfgIface()->
- openSockets(AF_INET6, srv->getServerPort(), srv->serverLock());
+ openSockets(AF_INET6, srv->getServerPort());
// Install the timers for handling leases reclamation.
try {
// LOG_ERROR(dhcp6_logger, DHCP6_SRV_DHCP4O6_ERROR).arg(ex.what());
}
- IfaceMgr::instance().closeSockets(serverLock());
+ IfaceMgr::instance().closeSockets();
LeaseMgrFactory::destroy();
}
Pkt6Ptr Dhcpv6Srv::receivePacket(int timeout) {
- return (IfaceMgr::instance().receive6(timeout, 0, serverLock()));
+ return (IfaceMgr::instance().receive6(timeout));
}
void Dhcpv6Srv::sendPacket(const Pkt6Ptr& packet) {
while (!shutdown_) {
try {
run_one();
- {
- LockGuard<mutex> lock(serverLock());
- getIOService()->poll();
- }
+ getIOService()->poll();
} catch (const std::exception& e) {
// General catch-all standard exceptions that are not caught by more
// specific catches.
// because it is important that the select() returns control
// frequently so as the IOService can be polled for ready handlers.
uint32_t timeout = 1;
- {
- // LOG_DEBUG(packet6_logger, DBG_DHCP6_DETAIL, DHCP6_BUFFER_WAIT).arg(timeout);
- LockGuard<mutex> lock(serverLock());
- query = receivePacket(timeout);
- }
+ // LOG_DEBUG(packet6_logger, DBG_DHCP6_DETAIL, DHCP6_BUFFER_WAIT).arg(timeout);
+ query = receivePacket(timeout);
// Log if packet has arrived. We can't log the detailed information
// about the DHCP message because it hasn't been unpacked/parsed
// process could wait up to the duration of timeout of select() to
// terminate.
try {
- LockGuard<mutex> lock(serverLock());
handleSignal();
} catch (const std::exception& e) {
// An (a standard or ISC) exception occurred.
void
Dhcpv6Srv::processPacketAndSendResponse(Pkt6Ptr& query, Pkt6Ptr& rsp) {
- LockGuard<mutex> lock(serverLock());
processPacket(query, rsp);
if (!rsp) {
return;
/// @brief returns Kea DHCPv6 server max thread queue size.
static uint32_t maxThreadQueueSize();
- /// @brief returns Kea DHCPv6 server mutex.
- std::mutex* serverLock() {
- return mutex_.get();
- }
-
/// @brief Returns server-identifier option.
///
/// @return server-id option
return (dhcp4o6_port_);
}
+ /// @brief Sets the server thread count.
+ ///
+ /// @param threads value of the server thread count
+ void setServerThreadCount(uint32_t threads) {
+ server_threads_ = threads;
+ }
+
+ /// @brief Retrieves the server thread count.
+ ///
+ /// @return value of the server thread count
+ uint32_t getServerThreadCount() const {
+ return (server_threads_);
+ }
+
+ /// @brief Sets the server max thread queue size.
+ ///
+ /// @param size max thread queue size
+ void setServerMaxThreadQueueSize(uint32_t size) {
+ server_max_thread_queue_size_ = size;
+ }
+
+ /// @brief Retrieves the server max thread queue size.
+ ///
+ /// @return value of the max thread queue size
+ uint32_t getServerMaxThreadQueueSize() const {
+ return (server_max_thread_queue_size_);
+ }
/// @brief Returns pointer to the D2 client configuration
D2ClientConfigPtr getD2ClientConfig() {
return (d2_client_config_);
/// this socket is bound and connected to this port and port + 1
uint16_t dhcp4o6_port_;
+ /// @brief The server thread count.
+ uint32_t server_threads_;
+
+ /// @brief The server max thread queue size.
+ uint32_t server_max_thread_queue_size_;
/// @brief Stores D2 client configuration
D2ClientConfigPtr d2_client_config_;
typedef boost::shared_ptr<const SrvConfig> ConstSrvConfigPtr;
//@}
-} // namespace isc::dhcp
-} // namespace isc
+} // namespace dhcp
+} // namespace isc
#endif // DHCPSRV_CONFIG_H