requester: Enhance the PLDM requester code
- Free the instance id on error paths
- Make the conditional checks consistent
- Make the unit tests robust
Signed-off-by: Tom Joseph <rushtotom@gmail.com>
Change-Id: Ieb70da2820ab818c36f5bf874a602fb090659836
diff --git a/requester/handler.hpp b/requester/handler.hpp
index 2082f69..319cb8e 100644
--- a/requester/handler.hpp
+++ b/requester/handler.hpp
@@ -171,8 +171,9 @@
event.get(), instanceIdExpiryCallBack);
auto rc = request->start();
- if (rc != PLDM_SUCCESS)
+ if (rc)
{
+ requester.markFree(eid, instanceId);
std::cerr << "Failure to send the PLDM request message"
<< "\n";
return rc;
@@ -184,6 +185,7 @@
}
catch (const std::runtime_error& e)
{
+ requester.markFree(eid, instanceId);
std::cerr << "Failed to start the instance ID expiry timer. RC = "
<< e.what() << "\n";
return PLDM_ERROR;