#include <cc/data.h>
#include <cc/json_feed.h>
#include <config/client_connection.h>
+#include <config/timeouts.h>
#include <boost/pointer_cast.hpp>
#include <iterator>
#include <sstream>
using namespace isc::hooks;
using namespace isc::process;
-namespace {
-
-/// @brief Client side connection timeout.
-/// @todo Make it configurable.
-const long CONNECTION_TIMEOUT = 60000;
-
-}
-
namespace isc {
namespace agent {
// Got the IO service so stop IO service. This causes to
// stop IO service when all handlers have been invoked.
io_service->stopWork();
- }, ClientConnection::Timeout(CONNECTION_TIMEOUT));
+ }, ClientConnection::Timeout(TIMEOUT_AGENT_FORWARD_COMMAND));
io_service->run();
if (received_ec) {
-// Copyright (C) 2016-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2016-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
#include <asiolink/io_address.h>
#include <asiolink/io_error.h>
#include <cc/command_interpreter.h>
+#include <config/timeouts.h>
#include <boost/pointer_cast.hpp>
using namespace isc::asiolink;
+using namespace isc::config;
using namespace isc::data;
using namespace isc::http;
using namespace isc::process;
-// Temporarily hardcoded configuration.
-/// @todo: remove once 5134 is merged.
-namespace {
-
-const long REQUEST_TIMEOUT = 10000;
-
-const long IDLE_TIMEOUT = 30000;
-
-}
namespace isc {
namespace agent {
// Create http listener. It will open up a TCP socket and be
// prepared to accept incoming connection.
- HttpListenerPtr
- http_listener(new HttpListener(*getIoService(), server_address,
- server_port, rcf,
- HttpListener::RequestTimeout(REQUEST_TIMEOUT),
- HttpListener::IdleTimeout(IDLE_TIMEOUT)));
+ HttpListenerPtr http_listener
+ (new HttpListener(*getIoService(), server_address,
+ server_port, rcf,
+ HttpListener::RequestTimeout(TIMEOUT_AGENT_RECEIVE_COMMAND),
+ HttpListener::IdleTimeout(TIMEOUT_AGENT_IDLE_CONNECTION_TIMEOUT)));
// Instruct the http listener to actually open socket, install
// callback and start listening.
#include <asiolink/io_service.h>
#include <cc/command_interpreter.h>
#include <config/command_mgr.h>
+#include <config/timeouts.h>
#include <dhcp/dhcp4.h>
#include <dhcp4/ctrl_dhcp4_srv.h>
#include <dhcp4/tests/dhcp4_test_utils.h>
using Dhcpv4Srv::network_state_;
};
-/// @brief Default control connection timeout.
-const size_t DEFAULT_CONNECTION_TIMEOUT = 10;
-
/// @brief Fixture class intended for testin control channel in the DHCPv4Srv
class CtrlChannelDhcpv4SrvTest : public ::testing::Test {
public:
CommandMgr::instance().closeCommandSocket();
CommandMgr::instance().deregisterAll();
- CommandMgr::instance().setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT);
+ CommandMgr::instance().setConnectionTimeout(TIMEOUT_DHCP_SERVER_RECEIVE_COMMAND);
server_.reset();
};
// Set connection timeout to 2s to prevent long waiting time for the
// timeout during this test.
- const unsigned short timeout = 2;
+ const unsigned short timeout = 2000;
CommandMgr::instance().setConnectionTimeout(timeout);
// Server's response will be assigned to this variable.
// Set connection timeout to 2s to prevent long waiting time for the
// timeout during this test.
- const unsigned short timeout = 2;
+ const unsigned short timeout = 2000;
CommandMgr::instance().setConnectionTimeout(timeout);
// Server's response will be assigned to this variable.
};
/// @brief Default control connection timeout.
-const size_t DEFAULT_CONNECTION_TIMEOUT = 10;
+const size_t DEFAULT_CONNECTION_TIMEOUT = 10000;
class CtrlDhcpv6SrvTest : public BaseServerTest {
public:
// Set connection timeout to 2s to prevent long waiting time for the
// timeout during this test.
- const unsigned short timeout = 2;
+ const unsigned short timeout = 2000;
CommandMgr::instance().setConnectionTimeout(timeout);
// Server's response will be assigned to this variable.
// Set connection timeout to 2s to prevent long waiting time for the
// timeout during this test.
- const unsigned short timeout = 2;
+ const unsigned short timeout = 2000;
CommandMgr::instance().setConnectionTimeout(timeout);
// Server's response will be assigned to this variable.
libkea_cfgclient_la_SOURCES += command_mgr.cc command_mgr.h
libkea_cfgclient_la_SOURCES += config_log.h config_log.cc
libkea_cfgclient_la_SOURCES += hooked_command_mgr.cc hooked_command_mgr.h
+libkea_cfgclient_la_SOURCES += timeouts.h
libkea_cfgclient_la_LIBADD = $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
libkea_cfgclient_la_LIBADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
cmds_impl.h \
command_mgr.h \
config_log.h \
- hooked_command_mgr.h
-
+ hooked_command_mgr.h \
+ timeouts.h
#include <cc/json_feed.h>
#include <dhcp/iface_mgr.h>
#include <config/config_log.h>
+#include <config/timeouts.h>
#include <util/watch_socket.h>
#include <boost/bind.hpp>
#include <boost/enable_shared_from_this.hpp>
/// @brief Maximum size of the data chunk sent/received over the socket.
const size_t BUF_SIZE = 8192;
-/// @brief Default connection timeout in seconds.
-const unsigned short DEFAULT_CONNECTION_TIMEOUT = 10;
-
class ConnectionPool;
/// @brief Represents a single connection over control socket.
Connection(const IOServicePtr& io_service,
const boost::shared_ptr<UnixDomainSocket>& socket,
ConnectionPool& connection_pool,
- const unsigned short timeout)
+ const long timeout)
: socket_(socket), timeout_timer_(*io_service), timeout_(timeout),
buf_(), response_(), connection_pool_(connection_pool), feed_(),
response_in_progress_(false), watch_socket_(new util::WatchSocket()) {
/// @brief This method schedules timer or reschedules existing timer.
void scheduleTimer() {
timeout_timer_.setup(boost::bind(&Connection::timeoutHandler, this),
- timeout_ * 1000, IntervalTimer::ONE_SHOT);
+ timeout_, IntervalTimer::ONE_SHOT);
}
/// @brief Close current connection.
/// @brief Interval timer used to detect connection timeouts.
IntervalTimer timeout_timer_;
- /// @brief Connection timeout (in seconds)
- unsigned short timeout_;
+ /// @brief Connection timeout (in milliseconds)
+ long timeout_;
/// @brief Buffer used for received data.
std::array<char, BUF_SIZE> buf_;
/// @brief Constructor.
CommandMgrImpl()
: io_service_(), acceptor_(), socket_(), socket_name_(),
- connection_pool_(), timeout_(DEFAULT_CONNECTION_TIMEOUT) {
+ connection_pool_(), timeout_(TIMEOUT_DHCP_SERVER_RECEIVE_COMMAND) {
}
/// @brief Opens acceptor service allowing the control clients to connect.
ConnectionPool connection_pool_;
/// @brief Connection timeout
- unsigned short timeout_;
+ long timeout_;
};
void
}
void
-CommandMgr::setConnectionTimeout(const unsigned short timeout) {
+CommandMgr::setConnectionTimeout(const long timeout) {
impl_->timeout_ = timeout;
}
/// @brief Override default connection timeout.
///
- /// @param timeout New connection timeout in seconds.
- void setConnectionTimeout(const unsigned short timeout);
+ /// @param timeout New connection timeout in milliseconds.
+ void setConnectionTimeout(const long timeout);
/// @brief Opens control socket with parameters specified in socket_info
///
--- /dev/null
+// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#ifndef CONFIG_TIMEOUTS_H
+#define CONFIG_TIMEOUTS_H
+
+namespace isc {
+namespace config {
+
+// All timeouts provided below are in milliseconds.
+
+/// @brief Timeout for the DHCP server to receive command over the
+/// unix domain socket.
+constexpr long TIMEOUT_DHCP_SERVER_RECEIVE_COMMAND = 10000;
+
+/// @brief Timeout for the Control Agent to receive command over the
+/// RESTful interface.
+constexpr long TIMEOUT_AGENT_RECEIVE_COMMAND = 10000;
+
+/// @brief Timeout for the idle connection to be closed.
+constexpr long TIMEOUT_AGENT_IDLE_CONNECTION_TIMEOUT = 30000;
+
+/// @brief Timeout for the Control Agent to forward command to a
+/// Kea server, e.g. DHCP server.
+///
+/// This value is high to ensure that the server have enough time
+/// to generate large responses, e.g. dump whole lease databse.
+constexpr long TIMEOUT_AGENT_FORWARD_COMMAND = 60000;
+
+} // end of namespace isc::config
+} // end of namespace isc
+
+#endif // CONFIG_TIMEOUTS_H