summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2014-03-22 13:49:48 +0000
committerrandomdan <randomdan@localhost>2014-03-22 13:49:48 +0000
commit4c92784e3903ec635519fe90d705c734a1290109 (patch)
tree122267204a6656acb57924c5db9cbfea4b68332c
parentClose remaining open file handles on exit (diff)
downloadnetfs-4c92784e3903ec635519fe90d705c734a1290109.tar.bz2
netfs-4c92784e3903ec635519fe90d705c734a1290109.tar.xz
netfs-4c92784e3903ec635519fe90d705c734a1290109.zip
Annoyingly pessimistic locking around open handle proxy lookups
-rw-r--r--netfs/fuse/fuseDirs.cpp13
-rw-r--r--netfs/fuse/fuseFiles.cpp31
2 files changed, 35 insertions, 9 deletions
diff --git a/netfs/fuse/fuseDirs.cpp b/netfs/fuse/fuseDirs.cpp
index fac70a6..216d032 100644
--- a/netfs/fuse/fuseDirs.cpp
+++ b/netfs/fuse/fuseDirs.cpp
@@ -19,7 +19,6 @@ NetFS::FuseApp::setProxy(OpenDirPtr od, uint64_t & fh)
NetFS::FuseApp::OpenDirPtr
NetFS::FuseApp::getDirProxy(uint64_t localID) const
{
- SLOCK;
OpenDirs::const_iterator i = openDirs.find(localID);
if (i != openDirs.end()) {
return i->second;
@@ -51,7 +50,11 @@ int
NetFS::FuseApp::releasedir(const char *, struct fuse_file_info * fi)
{
try {
- auto remote = getDirProxy(fi->fh)->remote;
+ DirectoryPrx remote;
+ {
+ LOCK;
+ remote = getDirProxy(fi->fh)->remote;
+ }
remote->close();
clearDirProxy(fi->fh);
return 0;
@@ -65,7 +68,11 @@ int
NetFS::FuseApp::readdir(const char *, void * buf, fuse_fill_dir_t filler, off_t, struct fuse_file_info * fi)
{
try {
- auto remote = getDirProxy(fi->fh)->remote;
+ DirectoryPrx remote;
+ {
+ LOCK;
+ remote = getDirProxy(fi->fh)->remote;
+ }
NetFS::NameList ds = remote->readdir();
BOOST_FOREACH(const auto & e, ds) {
filler(buf, e.c_str(), NULL, 0);
diff --git a/netfs/fuse/fuseFiles.cpp b/netfs/fuse/fuseFiles.cpp
index 4a96e51..c8d2495 100644
--- a/netfs/fuse/fuseFiles.cpp
+++ b/netfs/fuse/fuseFiles.cpp
@@ -21,7 +21,6 @@ NetFS::FuseApp::setProxy(OpenFilePtr of, uint64_t & fh)
NetFS::FuseApp::OpenFilePtr
NetFS::FuseApp::getFileProxy(uint64_t localID) const
{
- SLOCK;
OpenFiles::const_iterator i = openFiles.find(localID);
if (i != openFiles.end()) {
return i->second;
@@ -66,7 +65,11 @@ int
NetFS::FuseApp::release(const char *, struct fuse_file_info * fi)
{
try {
- auto remote = getFileProxy(fi->fh)->remote;
+ FilePrx remote;
+ {
+ LOCK;
+ remote = getFileProxy(fi->fh)->remote;
+ }
remote->close();
clearFileProxy(fi->fh);
return 0;
@@ -80,7 +83,11 @@ int
NetFS::FuseApp::read(const char *, char * buf, size_t s, off_t o, struct fuse_file_info * fi)
{
try {
- auto remote = getFileProxy(fi->fh)->remote;
+ FilePrx remote;
+ {
+ LOCK;
+ remote = getFileProxy(fi->fh)->remote;
+ }
NetFS::Buffer data = remote->read(o, s);
memcpy(buf, &data.front(), data.size());
return data.size();
@@ -94,7 +101,11 @@ int
NetFS::FuseApp::write(const char *, const char * buf, size_t s, off_t o, struct fuse_file_info * fi)
{
try {
- auto remote = getFileProxy(fi->fh)->remote;
+ FilePrx remote;
+ {
+ LOCK;
+ remote = getFileProxy(fi->fh)->remote;
+ }
remote->write(o, s, NetFS::Buffer(buf, buf + s));
return s;
}
@@ -119,7 +130,11 @@ int
NetFS::FuseApp::ftruncate(const char *, off_t o, fuse_file_info * fi)
{
try {
- auto remote = getFileProxy(fi->fh)->remote;
+ FilePrx remote;
+ {
+ LOCK;
+ remote = getFileProxy(fi->fh)->remote;
+ }
remote->ftruncate(reqEnv(), o);
return 0;
}
@@ -132,7 +147,11 @@ int
NetFS::FuseApp::fgetattr(const char *, struct stat * s, fuse_file_info * fi)
{
try {
- auto remote = getFileProxy(fi->fh)->remote;
+ FilePrx remote;
+ {
+ LOCK;
+ remote = getFileProxy(fi->fh)->remote;
+ }
*s << AttrSource { remote->fgetattr(reqEnv()), boost::bind(&UserEntCache::getID, &uentries, _1), boost::bind(&GroupEntCache::getID, &gentries, _1) };
return 0;
}