From 1c3bee2495a505e12949ab72fbf6a17f9c2db049 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 26 Apr 2022 00:33:37 +0100 Subject: Support getting daemon settings into the client. Unused as yet. --- netfs/daemon/daemonService.cpp | 7 +++++++ netfs/daemon/daemonService.h | 1 + netfs/fuse/fuseApp.cpp | 1 + netfs/fuse/fuseApp.h | 1 + netfs/ice/service.ice | 2 +- netfs/ice/types.ice | 4 ++++ netfs/unittests/mockFuse.cpp | 1 + netfs/unittests/testCore.cpp | 9 +++++++++ 8 files changed, 25 insertions(+), 1 deletion(-) diff --git a/netfs/daemon/daemonService.cpp b/netfs/daemon/daemonService.cpp index 38d40c7..03f60be 100644 --- a/netfs/daemon/daemonService.cpp +++ b/netfs/daemon/daemonService.cpp @@ -20,3 +20,10 @@ ServiceServer::connect(const std::string share, const std::string authtoken, con return Ice::uncheckedCast(ice.adapter->addFacetWithUUID( std::make_shared(ex->RootPath, userLookup, groupLookup), "v01")); } + +NetFS::SettingsPtr +ServiceServer::getSettings(const Ice::Current & ice) +{ + const auto props = ice.adapter->getCommunicator()->getProperties(); + return std::make_shared(props->getPropertyAsIntWithDefault("Ice.MessageSizeMax", 1024)); +} diff --git a/netfs/daemon/daemonService.h b/netfs/daemon/daemonService.h index fe79e21..1b240c2 100644 --- a/netfs/daemon/daemonService.h +++ b/netfs/daemon/daemonService.h @@ -10,6 +10,7 @@ public: explicit ServiceServer(NetFS::Daemon::ConfigurationPtr c); NetFS::VolumePrxPtr connect(const std::string share, const std::string auth, const Ice::Current &) override; + NetFS::SettingsPtr getSettings(const Ice::Current &) override; private: EntryResolverPtr userLookup; diff --git a/netfs/fuse/fuseApp.cpp b/netfs/fuse/fuseApp.cpp index 159febf..ffb46e5 100644 --- a/netfs/fuse/fuseApp.cpp +++ b/netfs/fuse/fuseApp.cpp @@ -185,6 +185,7 @@ NetFS::FuseApp::connectToService() if (!service) { throw std::runtime_error("Invalid service proxy: " + proxyAddr); } + daemonSettings = service->getSettings(); } } diff --git a/netfs/fuse/fuseApp.h b/netfs/fuse/fuseApp.h index 78cdf06..8feb58a 100644 --- a/netfs/fuse/fuseApp.h +++ b/netfs/fuse/fuseApp.h @@ -102,6 +102,7 @@ namespace NetFS { NetFS::VolumePrxPtr volume; NetFS::ServicePrxPtr service; Glacier2::SessionPrxPtr session; + NetFS::SettingsPtr daemonSettings; bool sessionOpened {false}; std::string mountPoint; diff --git a/netfs/ice/service.ice b/netfs/ice/service.ice index a3c3e3b..1d13e8d 100644 --- a/netfs/ice/service.ice +++ b/netfs/ice/service.ice @@ -6,7 +6,7 @@ module NetFS { interface Service { - // NameList volumes() throws ConfigError; Volume * connect(string volume, string auth) throws AuthError, ConfigError; + Settings getSettings(); }; }; diff --git a/netfs/ice/types.ice b/netfs/ice/types.ice index 9f0b6e2..3ca6b07 100644 --- a/netfs/ice/types.ice +++ b/netfs/ice/types.ice @@ -36,6 +36,10 @@ module NetFS { string grp; }; + class Settings { + optional(0) int MessageSizeMax; + }; + sequence Buffer; sequence NameList; diff --git a/netfs/unittests/mockFuse.cpp b/netfs/unittests/mockFuse.cpp index 5f28c95..35bc61d 100644 --- a/netfs/unittests/mockFuse.cpp +++ b/netfs/unittests/mockFuse.cpp @@ -31,6 +31,7 @@ FuseMock::connectToService() if (!service) { throw std::runtime_error("Invalid service proxy: " + testEndpoint); } + daemonSettings = service->getSettings(); } } diff --git a/netfs/unittests/testCore.cpp b/netfs/unittests/testCore.cpp index 0807dab..5e7e65e 100644 --- a/netfs/unittests/testCore.cpp +++ b/netfs/unittests/testCore.cpp @@ -109,6 +109,15 @@ BOOST_AUTO_TEST_CASE(daemonInitialised) volume->disconnect(); } +BOOST_AUTO_TEST_CASE(daemonSettings) +{ + auto service = Ice::checkedCast(ic->stringToProxy("Service")); + auto settings = service->getSettings(); + BOOST_REQUIRE(settings); + BOOST_REQUIRE(settings->MessageSizeMax); + BOOST_CHECK_EQUAL(1024, *settings->MessageSizeMax); +} + BOOST_AUTO_TEST_CASE(clientInitialised) { struct statvfs s; -- cgit v1.2.3