summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--manager.cpp55
-rw-r--r--manager.hpp4
2 files changed, 9 insertions, 50 deletions
diff --git a/manager.cpp b/manager.cpp
index 286b81a..15ff083 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -25,55 +25,18 @@
namespace blobs
{
-void BlobManager::incrementOpen(const std::string& path)
-{
- if (path.empty())
- {
- return;
- }
-
- openFiles[path] += 1;
-}
-
-void BlobManager::decrementOpen(const std::string& path)
-{
- if (path.empty())
- {
- return;
- }
-
- /* TODO(venture): Check into the iterator from find, does it makes sense
- * to just update it directly? */
- auto entry = openFiles.find(path);
- if (entry != openFiles.end())
- {
- /* found it, decrement it and remove it if 0. */
- openFiles[path] -= 1;
- if (openFiles[path] == 0)
- {
- openFiles.erase(path);
- }
- }
-}
-
-int BlobManager::getOpen(const std::string& path) const
-{
- /* No need to input check on the read-only call. */
- auto entry = openFiles.find(path);
- if (entry != openFiles.end())
- {
- return entry->second;
- }
-
- return 0;
-}
-
void BlobManager::eraseSession(GenericBlobInterface* handler, uint16_t session)
{
sessions.erase(session);
/* Ok for openSessions[handler] to be an empty set */
openSessions[handler].erase(session);
- decrementOpen(getPath(session));
+
+ auto path = getPath(session);
+ openFiles[path]--;
+ if (openFiles[path] == 0)
+ {
+ openFiles.erase(path);
+ }
}
void BlobManager::cleanUpStaleSessions(GenericBlobInterface* handler)
@@ -189,7 +152,7 @@ bool BlobManager::open(uint16_t flags, const std::string& path,
/* Associate session with handler */
sessions[*session] = SessionInfo(path, handler, flags);
openSessions[handler].insert(*session);
- incrementOpen(path);
+ openFiles[path]++;
return true;
}
@@ -310,7 +273,7 @@ bool BlobManager::deleteBlob(const std::string& path)
}
/* Check if the file has any open handles. */
- if (getOpen(path) > 0)
+ if (openFiles[path] > 0)
{
return false;
}
diff --git a/manager.hpp b/manager.hpp
index 011fe88..cba7935 100644
--- a/manager.hpp
+++ b/manager.hpp
@@ -276,10 +276,6 @@ class BlobManager : public ManagerInterface
std::string getPath(uint16_t session) const;
private:
- void incrementOpen(const std::string& path);
- void decrementOpen(const std::string& path);
- int getOpen(const std::string& path) const;
-
/* Helper method to erase a session from all maps */
void eraseSession(GenericBlobInterface* handler, uint16_t session);
/* For each session owned by this handler, call expire if it is stale */
OpenPOWER on IntegriCloud