summaryrefslogtreecommitdiff
path: root/include/image_upload.hpp
diff options
context:
space:
mode:
authorLei YU <mine260309@gmail.com>2019-03-08 11:52:10 +0300
committerEd Tanous <ed.tanous@intel.com>2019-03-10 00:05:53 +0300
commit9f898f8f29ba50d294ce249f4b2f41efcd14c791 (patch)
tree3eda4d0217179d69b79061058e7a28fad67621ef /include/image_upload.hpp
parent99cffd7f78aaacaffab2c75c85863cc7aeee3cbe (diff)
downloadbmcweb-9f898f8f29ba50d294ce249f4b2f41efcd14c791.tar.xz
REST: Increase timeout for image upload
The timeout was 10 seconds for: 1. The uploaded contenet is written to tmpfs 2. Wait for software version manager to parse the content and create the version object. For a tarball without compression, the timeout is enough, but for a compressed tarball, the timeout may not be enough, e.g. Palmetto takes about 9.x seconds to decompress the PNOR tarball. Change the timeout to 15 seconds, and start the timer after the file is written to tmpfs. Partially resovles openbmc/bmcweb#60 Tested: Verify no more 400 error on uploading gzipped tarball. Change-Id: I4e621236ed0c10892f8a5fef0d6a3ca2af911e93 Signed-off-by: Lei YU <mine260309@gmail.com>
Diffstat (limited to 'include/image_upload.hpp')
-rw-r--r--include/image_upload.hpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/include/image_upload.hpp b/include/image_upload.hpp
index 6bf56616eb..867d1bc66f 100644
--- a/include/image_upload.hpp
+++ b/include/image_upload.hpp
@@ -32,9 +32,9 @@ inline void uploadImageHandler(const crow::Request& req, crow::Response& res,
static boost::asio::deadline_timer timeout(*req.ioService,
boost::posix_time::seconds(5));
- timeout.expires_from_now(boost::posix_time::seconds(10));
+ timeout.expires_from_now(boost::posix_time::seconds(15));
- timeout.async_wait([&res](const boost::system::error_code& ec) {
+ auto timeoutHandler = [&res](const boost::system::error_code& ec) {
fwUpdateMatcher = nullptr;
if (ec == asio::error::operation_aborted)
{
@@ -57,7 +57,7 @@ inline void uploadImageHandler(const crow::Request& req, crow::Response& res,
{"message", "400 Bad Request"},
{"status", "error"}};
res.end();
- });
+ };
std::function<void(sdbusplus::message::message&)> callback =
[&res](sdbusplus::message::message& m) {
@@ -110,6 +110,7 @@ inline void uploadImageHandler(const crow::Request& req, crow::Response& res,
std::ofstream::trunc);
out << req.body;
out.close();
+ timeout.async_wait(timeoutHandler);
}
template <typename... Middlewares> void requestRoutes(Crow<Middlewares...>& app)