From 832af5ce93a52125328a580cec7aa6a17994f5c6 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 14 Jun 2015 01:03:31 +0100 Subject: The communicator you get at create isn't the one you get at start and doesn't have properties --- netfs/daemon/daemon.cpp | 14 ++++++++------ netfs/daemon/daemon.h | 4 ++-- netfs/unittests/testCore.cpp | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/netfs/daemon/daemon.cpp b/netfs/daemon/daemon.cpp index 3ad6294..f703386 100644 --- a/netfs/daemon/daemon.cpp +++ b/netfs/daemon/daemon.cpp @@ -8,14 +8,15 @@ #include "ioHelpers.h" #include -NetFSDaemon::NetFSDaemon(const Ice::CommunicatorPtr & i) : - ic(i) +NetFSDaemon::NetFSDaemon() { } NetFSDaemon::~NetFSDaemon() { - adapter->deactivate(); + if (adapter) { + adapter->deactivate(); + } } std::string @@ -33,8 +34,9 @@ NetFSDaemon::hostname() // name = NetFSDaemonAdapter void -NetFSDaemon::start(const std::string & name, const Ice::CommunicatorPtr &, const Ice::StringSeq&) +NetFSDaemon::start(const std::string & name, const Ice::CommunicatorPtr & ic, const Ice::StringSeq&) { + this->ic = ic; Ice::PropertiesPtr props = ic->getProperties(); LoadConfiguration(props->getProperty("NetFSD.ConfigPath")); @@ -69,9 +71,9 @@ NetFSDaemon::stop() extern "C" { IceBox::Service * - createNetFSDaemon(Ice::CommunicatorPtr ic) + createNetFSDaemon(Ice::CommunicatorPtr) { - return new NetFSDaemon(ic); + return new NetFSDaemon(); } } diff --git a/netfs/daemon/daemon.h b/netfs/daemon/daemon.h index 7ed5cb4..1cf2d49 100644 --- a/netfs/daemon/daemon.h +++ b/netfs/daemon/daemon.h @@ -9,7 +9,7 @@ class NetFSDaemon : public IceBox::Service { public: - NetFSDaemon(const Ice::CommunicatorPtr &); + NetFSDaemon(); virtual ~NetFSDaemon(); virtual void start(const std::string&, const Ice::CommunicatorPtr&, const Ice::StringSeq&) override; @@ -21,7 +21,7 @@ class NetFSDaemon : public IceBox::Service { private: void LoadConfiguration(const boost::filesystem::path & path); - const Ice::CommunicatorPtr ic; + Ice::CommunicatorPtr ic; Ice::ObjectAdapterPtr adapter; NetFS::Daemon::RuntimeConfigurationPtr dc; diff --git a/netfs/unittests/testCore.cpp b/netfs/unittests/testCore.cpp index 1fc1817..02405d9 100644 --- a/netfs/unittests/testCore.cpp +++ b/netfs/unittests/testCore.cpp @@ -20,7 +20,7 @@ std::string testEndpoint("tcp -h localhost -p 12012"); class MockDaemon : public NetFSDaemon { public: - MockDaemon(const Ice::CommunicatorPtr & ic) : NetFSDaemon(ic) { } + MockDaemon() : NetFSDaemon() { } protected: virtual NetFS::Daemon::ConfigurationPtr ReadConfiguration(const boost::filesystem::path &) const override @@ -40,7 +40,7 @@ class MockDaemonHost { MockDaemonHost() : params({}), ic(Ice::initialize(params)), - daemon(new MockDaemon(ic)) + daemon(new MockDaemon()) { ic->getProperties()->setProperty("NetFSD.HostNameOverride", "unittest"); daemon->start("NetFSDaemonAdapter", ic, {}); -- cgit v1.2.3