Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
9bab1aae
Commit
9bab1aae
authored
Jul 04, 2017
by
Marcin Siodelski
Browse files
[5318] Default control connection timeout is now 10s.
parent
0a1a2538
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc
View file @
9bab1aae
...
...
@@ -84,6 +84,9 @@ public:
using
Dhcpv4Srv
::
receivePacket
;
};
/// @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:
...
...
@@ -114,6 +117,7 @@ public:
CommandMgr
::
instance
().
closeCommandSocket
();
CommandMgr
::
instance
().
deregisterAll
();
CommandMgr
::
instance
().
setConnectionTimeout
(
DEFAULT_CONNECTION_TIMEOUT
);
server_
.
reset
();
};
...
...
@@ -1307,6 +1311,11 @@ TEST_F(CtrlChannelDhcpv4SrvTest, longResponse) {
TEST_F
(
CtrlChannelDhcpv4SrvTest
,
connectionTimeout
)
{
createUnixChannelServer
();
// Set connection timeout to 2s to prevent long waiting time for the
// timeout during this test.
const
unsigned
short
timeout
=
2
;
CommandMgr
::
instance
().
setConnectionTimeout
(
timeout
);
// Server's response will be assigned to this variable.
std
::
string
response
;
...
...
@@ -1329,11 +1338,11 @@ TEST_F(CtrlChannelDhcpv4SrvTest, connectionTimeout) {
std
::
string
command
=
"{
\"
command
\"
:
\"
foo
\"
"
;
ASSERT_TRUE
(
client
->
sendCommand
(
command
));
// Let's wait up to 1
0
s for the server's response. The response
// Let's wait up to 1
5
s for the server's response. The response
// should arrive sooner assuming that the timeout mechanism for
// the server is working properly.
const
unsigned
int
timeout
=
1
0
;
ASSERT_TRUE
(
client
->
getResponse
(
response
,
10
));
const
unsigned
int
timeout
=
1
5
;
ASSERT_TRUE
(
client
->
getResponse
(
response
,
timeout
));
// Explicitly close the client's connection.
client
->
disconnectFromServer
();
...
...
src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc
View file @
9bab1aae
...
...
@@ -81,6 +81,9 @@ public:
using
Dhcpv6Srv
::
receivePacket
;
};
/// @brief Default control connection timeout.
const
size_t
DEFAULT_CONNECTION_TIMEOUT
=
10
;
class
CtrlDhcpv6SrvTest
:
public
BaseServerTest
{
public:
CtrlDhcpv6SrvTest
()
...
...
@@ -91,6 +94,8 @@ public:
virtual
~
CtrlDhcpv6SrvTest
()
{
LeaseMgrFactory
::
destroy
();
StatsMgr
::
instance
().
removeAll
();
CommandMgr
::
instance
().
setConnectionTimeout
(
DEFAULT_CONNECTION_TIMEOUT
);
reset
();
};
...
...
@@ -1326,6 +1331,11 @@ TEST_F(CtrlChannelDhcpv6SrvTest, longResponse) {
TEST_F
(
CtrlChannelDhcpv6SrvTest
,
connectionTimeout
)
{
createUnixChannelServer
();
// Set connection timeout to 2s to prevent long waiting time for the
// timeout during this test.
const
unsigned
short
timeout
=
2
;
CommandMgr
::
instance
().
setConnectionTimeout
(
timeout
);
// Server's response will be assigned to this variable.
std
::
string
response
;
...
...
@@ -1348,11 +1358,11 @@ TEST_F(CtrlChannelDhcpv6SrvTest, connectionTimeout) {
std
::
string
command
=
"{
\"
command
\"
:
\"
foo
\"
"
;
ASSERT_TRUE
(
client
->
sendCommand
(
command
));
// Let's wait up to 1
0
s for the server's response. The response
// Let's wait up to 1
5
s for the server's response. The response
// should arrive sooner assuming that the timeout mechanism for
// the server is working properly.
const
unsigned
int
timeout
=
1
0
;
ASSERT_TRUE
(
client
->
getResponse
(
response
,
10
));
const
unsigned
int
timeout
=
1
5
;
ASSERT_TRUE
(
client
->
getResponse
(
response
,
timeout
));
// Explicitly close the client's connection.
client
->
disconnectFromServer
();
...
...
src/lib/config/command_mgr.cc
View file @
9bab1aae
...
...
@@ -31,10 +31,8 @@ namespace {
/// @brief Maximum size of the data chunk sent/received over the socket.
const
size_t
BUF_SIZE
=
8192
;
/// @brief Specifies connection timeout in milliseconds.
///
/// @todo Make it configurable.
const
unsigned
CONNECTION_TIMEOUT
=
5000
;
/// @brief Default connection timeout in seconds.
const
unsigned
short
DEFAULT_CONNECTION_TIMEOUT
=
10
;
class
ConnectionPool
;
...
...
@@ -56,11 +54,13 @@ public:
/// for data transmission.
/// @param connection_pool Reference to the connection pool to which this
/// connection belongs.
/// @param timeout Connection timeout.
Connection
(
const
IOServicePtr
&
io_service
,
const
boost
::
shared_ptr
<
UnixDomainSocket
>&
socket
,
ConnectionPool
&
connection_pool
)
:
socket_
(
socket
),
timeout_timer_
(
*
io_service
),
buf_
(),
response_
(),
connection_pool_
(
connection_pool
),
feed_
(),
ConnectionPool
&
connection_pool
,
const
unsigned
short
timeout
)
:
socket_
(
socket
),
timeout_timer_
(
*
io_service
),
timeout_
(
timeout
),
buf_
(),
response_
(),
connection_pool_
(
connection_pool
),
feed_
(),
response_in_progress_
(
false
)
{
LOG_INFO
(
command_logger
,
COMMAND_SOCKET_CONNECTION_OPENED
)
...
...
@@ -74,7 +74,7 @@ public:
// Start timer for detecting timeouts.
timeout_timer_
.
setup
(
boost
::
bind
(
&
Connection
::
timeoutHandler
,
this
),
CONNECTION_TIMEOUT
,
IntervalTimer
::
ONE_SHOT
);
timeout_
*
1000
,
IntervalTimer
::
ONE_SHOT
);
}
/// @brief Destructor.
...
...
@@ -160,6 +160,9 @@ private:
/// @brief Interval timer used to detect connection timeouts.
IntervalTimer
timeout_timer_
;
/// @brief Connection timeout.
unsigned
short
timeout_
;
/// @brief Buffer used for received data.
std
::
array
<
char
,
BUF_SIZE
>
buf_
;
...
...
@@ -375,7 +378,7 @@ public:
/// @brief Constructor.
CommandMgrImpl
()
:
io_service_
(),
acceptor_
(),
socket_
(),
socket_name_
(),
connection_pool_
()
{
connection_pool_
()
,
timeout_
(
DEFAULT_CONNECTION_TIMEOUT
)
{
}
/// @brief Opens acceptor service allowing the control clients to connect.
...
...
@@ -405,6 +408,9 @@ public:
/// @brief Pool of connections.
ConnectionPool
connection_pool_
;
/// @brief Connection timeout
unsigned
short
timeout_
;
};
void
...
...
@@ -465,7 +471,8 @@ CommandMgrImpl::doAccept() {
if
(
!
ec
)
{
// New connection is arriving. Start asynchronous transmission.
ConnectionPtr
connection
(
new
Connection
(
io_service_
,
socket_
,
connection_pool_
));
connection_pool_
,
timeout_
));
connection_pool_
.
start
(
connection
);
}
else
if
(
ec
.
value
()
!=
boost
::
asio
::
error
::
operation_aborted
)
{
...
...
@@ -521,5 +528,11 @@ CommandMgr::setIOService(const IOServicePtr& io_service) {
impl_
->
io_service_
=
io_service
;
}
void
CommandMgr
::
setConnectionTimeout
(
const
unsigned
short
timeout
)
{
impl_
->
timeout_
=
timeout
;
}
};
// end of isc::config
};
// end of isc
src/lib/config/command_mgr.h
View file @
9bab1aae
...
...
@@ -54,6 +54,11 @@ public:
/// @param io_service Pointer to the IO service.
void
setIOService
(
const
asiolink
::
IOServicePtr
&
io_service
);
/// @brief Override default connection timeout.
///
/// @param timeout New connection timeout in seconds.
void
setConnectionTimeout
(
const
unsigned
short
timeout
);
/// @brief Opens control socket with parameters specified in socket_info
///
/// Currently supported types are:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment