Commit b09fdcc6 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

[1238] Sockets are now closed properly.

parent 4d97ef5c
......@@ -47,6 +47,8 @@ Dhcpv6Srv::Dhcpv6Srv(uint16_t port) {
Dhcpv6Srv::~Dhcpv6Srv() {
cout << "DHCPv6 Srv shutdown." << endl;
IfaceMgr::instance().closeSockets();
}
bool
......
......@@ -47,7 +47,7 @@ public:
Dhcpv6Srv(uint16_t port = DHCP6_SERVER_PORT);
/// @brief Destructor. Used during DHCPv6 service shutdown.
~Dhcpv6Srv();
virtual ~Dhcpv6Srv();
/// @brief Returns server-intentifier option
///
......
......@@ -134,8 +134,7 @@ IfaceMgr::IfaceMgr()
}
}
IfaceMgr::~IfaceMgr() {
void IfaceMgr::closeSockets() {
for (IfaceCollection::iterator iface = ifaces_.begin();
iface != ifaces_.end(); ++iface) {
......@@ -147,6 +146,11 @@ IfaceMgr::~IfaceMgr() {
iface->sockets_.clear();
}
}
IfaceMgr::~IfaceMgr() {
closeSockets();
// control_buf_ is deleted automatically (scoped_ptr)
control_buf_len_ = 0;
}
......
......@@ -301,6 +301,11 @@ public:
/// @param port specifies port number (usually DHCP6_SERVER_PORT)
void openSockets(uint16_t port);
/// @brief Closes all open sockets.
/// Is used in destructor, but also from Dhcpv4_srv and Dhcpv6_srv classes.
void closeSockets();
// don't use private, we need derived classes in tests
protected:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment