From 328ed627c54165d75fc382487947ac05d7888027 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 15 Feb 2015 15:12:40 +0000 Subject: Make more testable --- netfs/daemon/Jamfile.jam | 6 ++++++ netfs/daemon/daemon.cpp | 23 ++++++++++++++++------- netfs/daemon/daemon.h | 10 ++++++---- netfs/daemon/daemonService.h | 1 + 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/netfs/daemon/Jamfile.jam b/netfs/daemon/Jamfile.jam index fd8c463..d42175d 100644 --- a/netfs/daemon/Jamfile.jam +++ b/netfs/daemon/Jamfile.jam @@ -50,6 +50,12 @@ lib netfsd : ..//IceBox ..//libxmlpp slicer-xml + : : + . + ../ice//netfsComms + netfsdConfiguration + netfsdConfiguration + ..//IceBox ; diff --git a/netfs/daemon/daemon.cpp b/netfs/daemon/daemon.cpp index d36e63f..6c231f9 100644 --- a/netfs/daemon/daemon.cpp +++ b/netfs/daemon/daemon.cpp @@ -8,19 +8,28 @@ #include "ioHelpers.h" #include +NetFSDaemon::NetFSDaemon(const Ice::CommunicatorPtr & i) : + ic(i) +{ +} + std::string NetFSDaemon::hostname() { - char buf[128]; - gethostname(buf, sizeof(buf)); - return buf; + auto props = ic->getProperties(); + auto hostNameOverride = props->getProperty("NetFSD.HostNameOverride"); + if (hostNameOverride.empty()) { + char buf[128]; + gethostname(buf, sizeof(buf)); + return buf; + } + return hostNameOverride; } // name = NetFSDaemonAdapter void -NetFSDaemon::start(const std::string & name, const Ice::CommunicatorPtr & ic, const Ice::StringSeq&) +NetFSDaemon::start(const std::string & name, const Ice::CommunicatorPtr &, const Ice::StringSeq&) { - this->ic = ic; Ice::PropertiesPtr props = ic->getProperties(); LoadConfiguration(props->getProperty("NetFSD.ConfigPath")); @@ -49,9 +58,9 @@ NetFSDaemon::stop() extern "C" { IceBox::Service * - createNetFSDaemon(Ice::CommunicatorPtr) + createNetFSDaemon(Ice::CommunicatorPtr ic) { - return new NetFSDaemon(); + return new NetFSDaemon(ic); } } diff --git a/netfs/daemon/daemon.h b/netfs/daemon/daemon.h index 471a296..58d9f2f 100644 --- a/netfs/daemon/daemon.h +++ b/netfs/daemon/daemon.h @@ -9,17 +9,19 @@ class NetFSDaemon : public IceBox::Service { public: - virtual void start(const std::string&, const Ice::CommunicatorPtr&, const Ice::StringSeq&); - virtual void stop(); + NetFSDaemon(const Ice::CommunicatorPtr &); + + virtual void start(const std::string&, const Ice::CommunicatorPtr&, const Ice::StringSeq&) override; + virtual void stop() override; private: void LoadConfiguration(const boost::filesystem::path & path); - Ice::CommunicatorPtr ic; + const Ice::CommunicatorPtr ic; Ice::ObjectAdapterPtr adapter; NetFS::Daemon::RuntimeConfigurationPtr dc; - static std::string hostname(); + std::string hostname(); }; class TempPrivs { diff --git a/netfs/daemon/daemonService.h b/netfs/daemon/daemonService.h index 783ad96..ab52eee 100644 --- a/netfs/daemon/daemonService.h +++ b/netfs/daemon/daemonService.h @@ -3,6 +3,7 @@ #include #include +#include class ServiceServer : public NetFS::Service { public: -- cgit v1.2.3