aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/nfs/FileReader.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-10-05 07:41:50 +0200
committerMax Kellermann <max@duempel.org>2014-10-05 07:41:50 +0200
commitb1a252a64d39d17618d2d00ac341684b6f290ef6 (patch)
tree10eff9b871e5bf9a6a7b8934ada5cf8a23920218 /src/lib/nfs/FileReader.cxx
parentfb90b64bac49d6efadc2db021cf0fbf65c9d66a6 (diff)
downloadmpd-b1a252a64d39d17618d2d00ac341684b6f290ef6.tar.gz
mpd-b1a252a64d39d17618d2d00ac341684b6f290ef6.tar.xz
mpd-b1a252a64d39d17618d2d00ac341684b6f290ef6.zip
lib/nfs/Base: kludge to reduce number of NFS mounts
Creating a NfsStorage sets its own export_name as the "base". Now NfsFileReader can use this information to derive the export_name to be mounted, instead of guessing. This solves the "too many connection" problem on the NFS server while updating the database.
Diffstat (limited to 'src/lib/nfs/FileReader.cxx')
-rw-r--r--src/lib/nfs/FileReader.cxx24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/lib/nfs/FileReader.cxx b/src/lib/nfs/FileReader.cxx
index d2be46f8e..4837e1f0e 100644
--- a/src/lib/nfs/FileReader.cxx
+++ b/src/lib/nfs/FileReader.cxx
@@ -20,6 +20,7 @@
#include "config.h"
#include "FileReader.hxx"
#include "Glue.hxx"
+#include "Base.hxx"
#include "Connection.hxx"
#include "Domain.hxx"
#include "event/Call.hxx"
@@ -100,14 +101,23 @@ NfsFileReader::Open(const char *uri, Error &error)
server = std::string(uri, slash);
uri = slash;
- slash = strrchr(uri + 1, '/');
- if (slash == nullptr || slash[1] == 0) {
- error.Set(nfs_domain, "Malformed nfs:// URI");
- return false;
- }
- export_name = std::string(uri, slash);
- path = slash;
+ const char *new_path = nfs_check_base(server.c_str(), uri);
+ if (new_path != nullptr) {
+ export_name = std::string(uri, new_path);
+ if (*new_path == 0)
+ new_path = "/";
+ path = new_path;
+ } else {
+ slash = strrchr(uri + 1, '/');
+ if (slash == nullptr || slash[1] == 0) {
+ error.Set(nfs_domain, "Malformed nfs:// URI");
+ return false;
+ }
+
+ export_name = std::string(uri, slash);
+ path = slash;
+ }
state = State::DEFER;
DeferredMonitor::Schedule();