Fix openFiles refcount
The old code deletes session from the session map before doing a lookup
of the path. Fix the order and add a unit test to catch the error case.
(The unit test would fail without this fix).
Signed-off-by: Kun Yi <kunyi731@gmail.com>
Change-Id: If043d6aad7bbaafa19ae3b63a6d9cc7a836d25b5
diff --git a/manager.cpp b/manager.cpp
index 0eec6f2..870bf60 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -27,7 +27,6 @@
void BlobManager::eraseSession(GenericBlobInterface* handler, uint16_t session)
{
- sessions.erase(session);
/* Ok for openSessions[handler] to be an empty set */
openSessions[handler].erase(session);
@@ -37,6 +36,8 @@
{
openFiles.erase(path);
}
+ /* Cannot erase before getPath() is called */
+ sessions.erase(session);
}
void BlobManager::cleanUpStaleSessions(GenericBlobInterface* handler)