Commit 9f776b72 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[805] Make sure SocketRequestor is initialized

The ModuleCCSession called the update of config which already needed the
SocketRequestor. But the requestor doesn't need the ModuleCCSession,
cc::Session is enough, so changing it and moving up in the
initialization process a little.
parent ab54494a
......@@ -159,6 +159,8 @@ main(int argc, char* argv[]) {
cc_session = new Session(io_service.get_io_service());
LOG_DEBUG(auth_logger, DBG_AUTH_START, AUTH_CONFIG_CHANNEL_CREATED);
// Initialize the Socket Requestor
isc::server_common::initSocketReqeustor(*cc_session);
// We delay starting listening to new commands/config just before we
// go into the main loop to avoid confusion due to mixture of
......@@ -169,8 +171,6 @@ main(int argc, char* argv[]) {
my_config_handler,
my_command_handler, false);
LOG_DEBUG(auth_logger, DBG_AUTH_START, AUTH_CONFIG_CHANNEL_ESTABLISHED);
// Initialize the Socket Requestor
isc::server_common::initSocketReqeustor(*config_session);
xfrin_session = new Session(io_service.get_io_service());
LOG_DEBUG(auth_logger, DBG_AUTH_START, AUTH_XFRIN_CHANNEL_CREATED);
......
......@@ -208,10 +208,10 @@ main(int argc, char* argv[]) {
LOG_DEBUG(resolver_logger, RESOLVER_DBG_INIT, RESOLVER_SERVICE_CREATED);
cc_session = new Session(io_service.get_io_service());
isc::server_common::initSocketReqeustor(*cc_session);
config_session = new ModuleCCSession(specfile, *cc_session,
my_config_handler,
my_command_handler);
isc::server_common::initSocketReqeustor(*config_session);
LOG_DEBUG(resolver_logger, RESOLVER_DBG_INIT, RESOLVER_CONFIG_CHANNEL);
// FIXME: This does not belong here, but inside Boss
......
......@@ -17,6 +17,7 @@
#include <server_common/logger.h>
#include <config/ccsession.h>
#include <cc/session.h>
#include <cc/data.h>
#include <util/io/fd.h>
#include <util/io/fd_share.h>
......@@ -245,13 +246,13 @@ getSocketFd(const std::string& token, int sock_pass_fd) {
}
// This implementation class for SocketRequestor uses
// a ModuleCCSession for communication with the boss process,
// a CC session for communication with the boss process,
// and fd_share to read out the socket(s).
// Since we only use a reference to the session, it must never
// be closed during the lifetime of this class
class SocketRequestorCCSession : public SocketRequestor {
public:
explicit SocketRequestorCCSession(config::ModuleCCSession& session) :
explicit SocketRequestorCCSession(cc::AbstractSession& session) :
session_(session)
{
// We need to filter SIGPIPE to prevent it from happening in
......@@ -283,12 +284,12 @@ public:
share_mode, share_name);
// Send it to boss
const int seq = session_.groupSendMsg(request_msg, "Boss");
const int seq = session_.group_sendmsg(request_msg, "Boss");
// Get the answer from the boss.
// Just do a blocking read, we can't really do much anyway
isc::data::ConstElementPtr env, recv_msg;
if (!session_.groupRecvMsg(env, recv_msg, false, seq)) {
if (!session_.group_recvmsg(env, recv_msg, false, seq)) {
isc_throw(isc::config::CCSessionError,
"Incomplete response when requesting socket");
}
......@@ -313,14 +314,14 @@ public:
createReleaseSocketMessage(token);
// Send it to boss
const int seq = session_.groupSendMsg(release_msg, "Boss");
const int seq = session_.group_sendmsg(release_msg, "Boss");
LOG_DEBUG(logger, DBGLVL_TRACE_DETAIL, SOCKETREQUESTOR_RELEASESOCKET).
arg(token);
// Get the answer from the boss.
// Just do a blocking read, we can't really do much anyway
isc::data::ConstElementPtr env, recv_msg;
if (!session_.groupRecvMsg(env, recv_msg, false, seq)) {
if (!session_.group_recvmsg(env, recv_msg, false, seq)) {
isc_throw(isc::config::CCSessionError,
"Incomplete response when sending drop socket command");
}
......@@ -363,7 +364,7 @@ private:
}
}
config::ModuleCCSession& session_;
cc::AbstractSession& session_;
std::map<std::string, int> fd_share_sockets_;
};
......@@ -379,7 +380,7 @@ socketRequestor() {
}
void
initSocketReqeustor(config::ModuleCCSession& session) {
initSocketReqeustor(cc::AbstractSession& session) {
if (requestor != NULL) {
isc_throw(InvalidOperation,
"The socket requestor was already initialized");
......
......@@ -24,8 +24,8 @@
namespace isc {
namespace config {
class ModuleCCSession;
namespace cc {
class AbstractSession;
};
namespace server_common {
......@@ -168,7 +168,7 @@ SocketRequestor& socketRequestor();
/// \param session the CC session that'll be used to talk to the
/// socket creator.
/// \throw InvalidOperation when it is called more than once
void initSocketReqeustor(config::ModuleCCSession& session);
void initSocketReqeustor(cc::AbstractSession& session);
/// \brief Initialization for tests
///
......
......@@ -81,14 +81,9 @@ class SocketRequestorTest : public ::testing::Test {
public:
SocketRequestorTest() : session(ElementPtr(new ListElement),
ElementPtr(new ListElement),
ElementPtr(new ListElement)),
specfile(std::string(TEST_DATA_PATH) +
"/spec.spec")
ElementPtr(new ListElement))
{
session.getMessages()->add(createAnswer());
cc_session.reset(new ModuleCCSession(specfile, session, NULL, NULL,
false, false));
initSocketReqeustor(*cc_session);
initSocketReqeustor(session);
}
~SocketRequestorTest() {
......@@ -124,7 +119,6 @@ public:
}
isc::cc::FakeSession session;
boost::scoped_ptr<ModuleCCSession> cc_session;
const std::string specfile;
};
......
Supports Markdown
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