diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-07-19 16:10:57 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-07-19 16:10:57 +0100 |
commit | 5ede31fe4d1619152d768869bdf25828b083b4d0 (patch) | |
tree | 455191edbe9b31a41e913b08fe506d670337fbac | |
parent | Enable router heartbeats (diff) | |
download | netfs-5ede31fe4d1619152d768869bdf25828b083b4d0.tar.bz2 netfs-5ede31fe4d1619152d768869bdf25828b083b4d0.tar.xz netfs-5ede31fe4d1619152d768869bdf25828b083b4d0.zip |
Look up the resource only once
-rw-r--r-- | netfs/fuse/fuseApp.cpp | 21 | ||||
-rw-r--r-- | netfs/fuse/fuseApp.h | 2 |
2 files changed, 10 insertions, 13 deletions
diff --git a/netfs/fuse/fuseApp.cpp b/netfs/fuse/fuseApp.cpp index 3531f88..964f412 100644 --- a/netfs/fuse/fuseApp.cpp +++ b/netfs/fuse/fuseApp.cpp @@ -49,7 +49,12 @@ void * NetFS::FuseApp::init(struct fuse_conn_info *) { ic = Ice::initialize(_argc, _argv); - fc = ReadConfiguration(configPath); + auto fc = ReadConfiguration(configPath); + auto e = fc->Resources.find(resourceName); + if (e == fc->Resources.end()) { + throw std::runtime_error("No such resource: " + resourceName); + } + fcr = e->second; return NULL; } @@ -98,13 +103,9 @@ NetFS::FuseApp::connectToService() { if (!service) { Lock(_lock); - auto e = fc->Resources.find(resourceName); - if (e == fc->Resources.end()) { - throw std::runtime_error("No such resource: " + resourceName); - } - auto proxyAddr = e->second->ServiceIdentity; - for (const auto & ep : e->second->Endpoints) { + auto proxyAddr = fcr->ServiceIdentity; + for (const auto & ep : fcr->Endpoints) { proxyAddr += ":" + ep; } service = NetFS::ServicePrx::checkedCast(ic->stringToProxy(proxyAddr)); @@ -118,11 +119,7 @@ void NetFS::FuseApp::connectToVolume() { if (!volume) { - auto e = fc->Resources.find(resourceName); - if (e == fc->Resources.end()) { - throw std::runtime_error("No such export: " + resourceName); - } - volume = service->connect(e->second->ExportName, "bar"); + volume = service->connect(fcr->ExportName, "bar"); if (!volume) { throw std::runtime_error("Invalid filesystem proxy"); } diff --git a/netfs/fuse/fuseApp.h b/netfs/fuse/fuseApp.h index 335a1c0..70dd335 100644 --- a/netfs/fuse/fuseApp.h +++ b/netfs/fuse/fuseApp.h @@ -99,7 +99,7 @@ namespace NetFS { int & _argc; char ** _argv; Ice::CommunicatorPtr ic; - Client::ConfigurationPtr fc; + Client::ResourcePtr fcr; mutable boost::shared_mutex _lock; NetFS::VolumePrx volume; |