diff options
| author | Vernon Mauery <vernon.mauery@linux.intel.com> | 2018-10-15 12:55:34 -0700 |
|---|---|---|
| committer | Vernon Mauery <vernon.mauery@linux.intel.com> | 2018-11-06 15:42:37 -0800 |
| commit | ae1fda44032a361874417c4006ddcbd951974399 (patch) | |
| tree | c179b19c47cdb3ef0114b89385370fc6a144614b /command | |
| parent | 9e801a2b5b36acd307606af5eafdb885dfe8daee (diff) | |
| download | phosphor-net-ipmid-ae1fda44032a361874417c4006ddcbd951974399.tar.gz phosphor-net-ipmid-ae1fda44032a361874417c4006ddcbd951974399.zip | |
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>
Diffstat (limited to 'command')
| -rw-r--r-- | command/open_session.cpp | 19 | ||||
| -rw-r--r-- | command/payload_cmds.cpp | 5 | ||||
| -rw-r--r-- | command/rakp12.cpp | 7 | ||||
| -rw-r--r-- | command/rakp34.cpp | 13 | ||||
| -rw-r--r-- | command/session_cmds.cpp | 5 | ||||
| -rw-r--r-- | command/sol_cmds.cpp | 3 |
6 files changed, 22 insertions, 30 deletions
diff --git a/command/open_session.cpp b/command/open_session.cpp index b41eefa..b48b7e9 100644 --- a/command/open_session.cpp +++ b/command/open_session.cpp @@ -50,16 +50,15 @@ std::vector<uint8_t> openSession(const std::vector<uint8_t>& inPayload, { // Start an IPMI session session = - (std::get<session::Manager&>(singletonPool) - .startSession( - endian::from_ipmi<>(request->remoteConsoleSessionID), - static_cast<session::Privilege>(request->maxPrivLevel), - static_cast<cipher::rakp_auth::Algorithms>( - request->authAlgo), - static_cast<cipher::integrity::Algorithms>( - request->intAlgo), - static_cast<cipher::crypt::Algorithms>(request->confAlgo))) - .lock(); + std::get<session::Manager&>(singletonPool) + .startSession( + endian::from_ipmi<>(request->remoteConsoleSessionID), + static_cast<session::Privilege>(request->maxPrivLevel), + static_cast<cipher::rakp_auth::Algorithms>( + request->authAlgo), + static_cast<cipher::integrity::Algorithms>( + request->intAlgo), + static_cast<cipher::crypt::Algorithms>(request->confAlgo)); } catch (std::exception& e) { diff --git a/command/payload_cmds.cpp b/command/payload_cmds.cpp index 8030b92..2e8ac6f 100644 --- a/command/payload_cmds.cpp +++ b/command/payload_cmds.cpp @@ -47,9 +47,8 @@ std::vector<uint8_t> activatePayload(const std::vector<uint8_t>& inPayload, return outPayload; } - auto session = (std::get<session::Manager&>(singletonPool) - .getSession(handler.sessionID)) - .lock(); + auto session = std::get<session::Manager&>(singletonPool) + .getSession(handler.sessionID); if (!request->encryption && session->isCryptAlgoEnabled()) { diff --git a/command/rakp12.cpp b/command/rakp12.cpp index b0aad87..b4842b2 100644 --- a/command/rakp12.cpp +++ b/command/rakp12.cpp @@ -35,10 +35,9 @@ std::vector<uint8_t> RAKP12(const std::vector<uint8_t>& inPayload, std::shared_ptr<session::Session> session; try { - session = (std::get<session::Manager&>(singletonPool) - .getSession( - endian::from_ipmi(request->managedSystemSessionID))) - .lock(); + session = + std::get<session::Manager&>(singletonPool) + .getSession(endian::from_ipmi(request->managedSystemSessionID)); } catch (std::exception& e) { diff --git a/command/rakp34.cpp b/command/rakp34.cpp index 76236d5..84c90fc 100644 --- a/command/rakp34.cpp +++ b/command/rakp34.cpp @@ -16,8 +16,7 @@ namespace command void applyIntegrityAlgo(const uint32_t bmcSessionID) { auto session = - (std::get<session::Manager&>(singletonPool).getSession(bmcSessionID)) - .lock(); + std::get<session::Manager&>(singletonPool).getSession(bmcSessionID); auto authAlgo = session->getAuthAlgo(); @@ -45,8 +44,7 @@ void applyIntegrityAlgo(const uint32_t bmcSessionID) void applyCryptAlgo(const uint32_t bmcSessionID) { auto session = - (std::get<session::Manager&>(singletonPool).getSession(bmcSessionID)) - .lock(); + std::get<session::Manager&>(singletonPool).getSession(bmcSessionID); auto authAlgo = session->getAuthAlgo(); @@ -96,10 +94,9 @@ std::vector<uint8_t> RAKP34(const std::vector<uint8_t>& inPayload, std::shared_ptr<session::Session> session; try { - session = (std::get<session::Manager&>(singletonPool) - .getSession( - endian::from_ipmi(request->managedSystemSessionID))) - .lock(); + session = + std::get<session::Manager&>(singletonPool) + .getSession(endian::from_ipmi(request->managedSystemSessionID)); } catch (std::exception& e) { diff --git a/command/session_cmds.cpp b/command/session_cmds.cpp index fb2d074..d363c1e 100644 --- a/command/session_cmds.cpp +++ b/command/session_cmds.cpp @@ -23,9 +23,8 @@ std::vector<uint8_t> response->completionCode = IPMI_CC_OK; uint8_t reqPrivilegeLevel = request->reqPrivLevel; - auto session = (std::get<session::Manager&>(singletonPool) - .getSession(handler.sessionID)) - .lock(); + auto session = std::get<session::Manager&>(singletonPool) + .getSession(handler.sessionID); if (reqPrivilegeLevel == 0) // Just return present privilege level { diff --git a/command/sol_cmds.cpp b/command/sol_cmds.cpp index fb6f19e..a8fa410 100644 --- a/command/sol_cmds.cpp +++ b/command/sol_cmds.cpp @@ -57,8 +57,7 @@ void activating(uint8_t payloadInstance, uint32_t sessionID) request->minorVersion = MINOR_VERSION; auto session = - (std::get<session::Manager&>(singletonPool).getSession(sessionID)) - .lock(); + std::get<session::Manager&>(singletonPool).getSession(sessionID); message::Handler msgHandler(session->channelPtr, sessionID); |

