From 6b54e4e08678c0e32ed02adc87237f6ffa936691 Mon Sep 17 00:00:00 2001 From: Ed Tanous Date: Wed, 10 Apr 2024 08:58:48 -0700 Subject: Handle error code properly As part of the previous patch tests, UpdateService shows this bug, where on a multipart parser failure, the dbus match object gets instantiated, and eventually fails. This leads to mediocre logging, and possibly could leave update service in an undesirable state. Fix the error by moving the conditional up. Tested: Filling a 16MB file with all zeros and sending it now no longer logs that a monitor has been set up, and returns immediately instead of waiting for timeout. ``` dd if=/dev/zero of=zeros-file bs=1048576 count=16 of=16mb.txt curl -k --location POST https://192.168.7.2/redfish/v1/UpdateService/update -F 'UpdateParameters={"Targets":[]} ;type=application/json' -H "Expect:" --user "root:0penBmc" -F UpdateFile=@16mb.txt -v ``` Change-Id: I0962d15c624936b4fa199a675123702003dd697b Signed-off-by: Ed Tanous --- redfish-core/lib/update_service.hpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp index 14f8ecfd61..0418d269b9 100644 --- a/redfish-core/lib/update_service.hpp +++ b/redfish-core/lib/update_service.hpp @@ -668,6 +668,7 @@ inline void setApplyTime(const std::shared_ptr& asyncResp, inline void updateMultipartContext(const std::shared_ptr& asyncResp, + const crow::Request& req, const MultipartParser& parser) { const std::string* uploadData = nullptr; @@ -754,6 +755,9 @@ inline void setApplyTime(asyncResp, *applyTime); + // Setup callback for when new software detected + monitorForSoftwareAvailable(asyncResp, req, "/redfish/v1/UpdateService"); + uploadImageFile(asyncResp->res, *uploadData); } @@ -783,10 +787,6 @@ inline void { MultipartParser parser; - // Setup callback for when new software detected - monitorForSoftwareAvailable(asyncResp, req, - "/redfish/v1/UpdateService"); - ParserError ec = parser.parse(req); if (ec != ParserError::PARSER_SUCCESS) { @@ -796,7 +796,8 @@ inline void messages::internalError(asyncResp->res); return; } - updateMultipartContext(asyncResp, parser); + + updateMultipartContext(asyncResp, req, parser); } else { -- cgit v1.2.3