netipmid: use std::shared_ptr instead of weak_ptr/lock
All of the instances of getSession and startSession were assigning the
result to a local shared_ptr via lock on the weak_ptr. It doesn't make
sense to demote the shared_ptr (from the sessionsMap) to a weak_ptr via
the return, only to promote to a shared_ptr again via lock.
Tested-by: running ipmitool -H a.b.c.d -P 0penBmc -I lanplus mc info
Sessions start and stop, same as before.
Change-Id: Ic10779285891d73ee51115f16ed0000b38d1c52a
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/message_parsers.cpp b/message_parsers.cpp
index 695b5b7..7497747 100644
--- a/message_parsers.cpp
+++ b/message_parsers.cpp
@@ -280,9 +280,8 @@
return false;
}
- auto session = (std::get<session::Manager&>(singletonPool)
- .getSession(message.bmcSessionID))
- .lock();
+ auto session = std::get<session::Manager&>(singletonPool)
+ .getSession(message.bmcSessionID);
auto integrityAlgo = session->getIntegrityAlgo();
@@ -322,9 +321,8 @@
trailer->padLength = paddingLen;
trailer->nextHeader = parser::RMCP_MESSAGE_CLASS_IPMI;
- auto session = (std::get<session::Manager&>(singletonPool)
- .getSession(message.bmcSessionID))
- .lock();
+ auto session = std::get<session::Manager&>(singletonPool)
+ .getSession(message.bmcSessionID);
auto integrityData =
session->getIntegrityAlgo()->generateIntegrityData(packet);
@@ -335,9 +333,8 @@
std::vector<uint8_t> decryptPayload(const std::vector<uint8_t>& packet,
const Message& message, size_t payloadLen)
{
- auto session = (std::get<session::Manager&>(singletonPool)
- .getSession(message.bmcSessionID))
- .lock();
+ auto session = std::get<session::Manager&>(singletonPool)
+ .getSession(message.bmcSessionID);
return session->getCryptAlgo()->decryptPayload(
packet, sizeof(SessionHeader_t), payloadLen);
@@ -345,9 +342,8 @@
std::vector<uint8_t> encryptPayload(Message& message)
{
- auto session = (std::get<session::Manager&>(singletonPool)
- .getSession(message.bmcSessionID))
- .lock();
+ auto session = std::get<session::Manager&>(singletonPool)
+ .getSession(message.bmcSessionID);
return session->getCryptAlgo()->encryptPayload(message.payload);
}