summaryrefslogtreecommitdiffstats
path: root/manager.cpp
diff options
context:
space:
mode:
authorKun Yi <kunyi731@gmail.com>2019-11-22 20:01:28 -0800
committerKun Yi <kunyi731@gmail.com>2019-11-25 10:18:55 -0800
commitbeee9e54ae3e20bce5e466773cfda9232382e2e7 (patch)
tree92a24e6ea40fc67d0ea70fe59032022fa5b0e971 /manager.cpp
parentcd833aa11075ac1041531270060e1fb3ba8aa5ac (diff)
downloadphosphor-ipmi-blobs-beee9e54ae3e20bce5e466773cfda9232382e2e7.tar.gz
phosphor-ipmi-blobs-beee9e54ae3e20bce5e466773cfda9232382e2e7.zip
cleanup: remove getPath
The getPath call is only used once. Getting rid of it makes it easier to understand. Signed-off-by: Kun Yi <kunyi731@gmail.com> Change-Id: Ifc8859f5fc68bb594003a6db7f7e80b1c1dfed28
Diffstat (limited to 'manager.cpp')
-rw-r--r--manager.cpp32
1 files changed, 13 insertions, 19 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. */
OpenPOWER on IntegriCloud