log_services: Fix redundant AsyncResp objects when deleting dump entries
In the doPost handler for clearing Dump entries, it may create
redundant AsyncResp objects in deleteDumpEntry(). This will cause
redundant execution of res->end() and lead to unexpected result
for subsequent request within the same connection.
Tested By:
- pass the openbmc-test-automation with the following case.
LogService Test
[Documentation] Test LogService
[Tags] Test_LogService
Create User Initiated BMC Dump
Redfish Delete All BMC Dumps
Redfish.Login
Signed-off-by: Stanley Chu <yschu@nuvoton.com>
Change-Id: I636cdf7a4c18072898660fd0eab1380e294d263c
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index ce5b2c8..39f1de5 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -659,11 +659,10 @@
"org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
}
-inline void deleteDumpEntry(crow::Response& res, const std::string& entryID,
+inline void deleteDumpEntry(const std::shared_ptr<AsyncResp>& asyncResp,
+ const std::string& entryID,
const std::string& dumpType)
{
- std::shared_ptr<AsyncResp> asyncResp = std::make_shared<AsyncResp>(res);
-
auto respHandler = [asyncResp](const boost::system::error_code ec) {
BMCWEB_LOG_DEBUG << "Dump Entry doDelete callback: Done";
if (ec)
@@ -847,7 +846,7 @@
if (pos != std::string::npos)
{
std::string logID = path.substr(pos + 1);
- deleteDumpEntry(asyncResp->res, logID, dumpType);
+ deleteDumpEntry(asyncResp, logID, dumpType);
}
}
},
@@ -2097,7 +2096,7 @@
messages::internalError(asyncResp->res);
return;
}
- deleteDumpEntry(asyncResp->res, params[0], "bmc");
+ deleteDumpEntry(asyncResp, params[0], "bmc");
}
};
@@ -2267,7 +2266,7 @@
messages::internalError(asyncResp->res);
return;
}
- deleteDumpEntry(asyncResp->res, params[0], "system");
+ deleteDumpEntry(asyncResp, params[0], "system");
}
};