Commit d8aee4ee authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[1539] make sure the forwarder connection is closed on destruction of authsrv.

parent bc6b92a8
......@@ -117,7 +117,11 @@ public:
SocketSessionForwarderHolder(BaseSocketSessionForwarder& forwarder) :
forwarder_(forwarder), connected_(false)
{}
~SocketSessionForwarderHolder() {}
~SocketSessionForwarderHolder() {
if (connected_) {
forwarder_.close();
}
}
void connect() {
if (!connected_) {
......
......@@ -14,10 +14,6 @@
#include <config.h>
#include <vector>
#include <boost/shared_ptr.hpp>
#include <gtest/gtest.h>
#include <dns/message.h>
......@@ -45,6 +41,11 @@
#include <testutils/portconfig.h>
#include <testutils/socket_request.h>
#include <boost/shared_ptr.hpp>
#include <boost/scoped_ptr.hpp>
#include <vector>
using namespace std;
using namespace isc::cc;
using namespace isc::dns;
......@@ -57,6 +58,7 @@ using namespace isc::asiolink;
using namespace isc::testutils;
using namespace isc::server_common::portconfig;
using isc::UnitTestUtil;
using boost::scoped_ptr;
namespace {
const char* const CONFIG_TESTDB =
......@@ -1407,4 +1409,20 @@ TEST_F(AuthSrvTest, DDNSForward) {
}
}
TEST_F(AuthSrvTest, DDNSForwardClose) {
scoped_ptr<AuthSrv> tmp_server(new AuthSrv(true, xfrout, ddns_forwarder));
UnitTestUtil::createRequestMessage(request_message, Opcode::UPDATE(),
default_qid, Name("example.com"),
RRClass::IN(), RRType::SOA());
createRequestPacket(request_message, IPPROTO_UDP);
tmp_server->processMessage(*io_message, *parse_message, *response_obuffer,
&dnsserv);
EXPECT_FALSE(dnsserv.hasAnswer());
EXPECT_TRUE(ddns_forwarder.isConnected());
// Destroy the server. The forwarder should close the connection.
tmp_server.reset();
EXPECT_FALSE(ddns_forwarder.isConnected());
}
}
......@@ -223,7 +223,9 @@ public:
}
is_connected_ = true;
}
virtual void close() {}
virtual void close() {
is_connected_ = false;
}
#if 0
virtual void push(int sock, int family, int type, int protocol,
const struct sockaddr& local_end,
......
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