diff options
-rw-r--r-- | manager.cpp | 32 | ||||
-rw-r--r-- | manager.hpp | 8 |
2 files changed, 13 insertions, 27 deletions
diff --git a/manager.cpp b/manager.cpp index 870bf60..64cc08f 100644 --- a/manager.cpp +++ b/manager.cpp @@ -27,17 +27,21 @@ namespace blobs void BlobManager::eraseSession(GenericBlobInterface* handler, uint16_t session) { - /* Ok for openSessions[handler] to be an empty set */ - openSessions[handler].erase(session); - - auto path = getPath(session); - openFiles[path]--; - if (openFiles[path] == 0) + if (auto item = sessions.find(session); item != sessions.end()) { - openFiles.erase(path); + const auto& blobId = item->second.blobId; + + /* Ok for openSessions[handler] to be an empty set */ + openSessions[handler].erase(session); + openFiles[blobId]--; + if (openFiles[blobId] == 0) + { + openFiles.erase(blobId); + } + + /* Erase at the end after using the session info */ + sessions.erase(session); } - /* Cannot erase before getPath() is called */ - sessions.erase(session); } void BlobManager::cleanUpStaleSessions(GenericBlobInterface* handler) @@ -183,16 +187,6 @@ GenericBlobInterface* BlobManager::getActionHandle(uint16_t session, return nullptr; } -std::string BlobManager::getPath(uint16_t session) const -{ - if (auto item = sessions.find(session); item != sessions.end()) - { - return item->second.blobId; - } - - return ""; -} - bool BlobManager::stat(const std::string& path, BlobMeta* meta) { /* meta should never be NULL. */ diff --git a/manager.hpp b/manager.hpp index 3097201..a7e9936 100644 --- a/manager.hpp +++ b/manager.hpp @@ -258,14 +258,6 @@ class BlobManager : public ManagerInterface uint16_t session, uint16_t requiredFlags = std::numeric_limits<uint16_t>::max()); - /** - * Given a session id will return associated path. - * - * @param[in] session - the session. - * @return the path or "" on failure. - */ - std::string getPath(uint16_t session) const; - private: /* Helper method to erase a session from all maps */ void eraseSession(GenericBlobInterface* handler, uint16_t session); |