summaryrefslogtreecommitdiff
path: root/http/http_client.hpp
diff options
context:
space:
mode:
authorCarson Labrado <clabrado@google.com>2022-07-12 01:26:21 +0300
committerEd Tanous <ed@tanous.net>2022-07-15 20:22:26 +0300
commit5cab68f307fe73709d3d13a4d3638fbd86b99e46 (patch)
tree6de7c17ea7f3f6bd4817c5732ad5dbb063cb16ce /http/http_client.hpp
parentbc20089a19981c390ffa26f23e37bc2aff96b0c4 (diff)
downloadbmcweb-5cab68f307fe73709d3d13a4d3638fbd86b99e46.tar.xz
HTTP Client: Fix handling on connection timeout
If a destination is not reachable, then the connection will timeout in doConnect(). This causes issues later when the client attempts to resend the message. The error check in doClose() should not exit early since that will result in the connection's status not being marked as closed and thus it will never get reused. Similarly, doCloseAndRetry() should not exit early since that will cause the retry flow to hang and the connection's callback function will not get deleted. Tested: Used Redfish Aggregation patches in the chain through https://gerrit.openbmc.org/c/openbmc/bmcweb/+/54896 to verify that requests to collections such as /redfish/v1/Chassis no longer hang when the specified Satellite BMC does not exist Signed-off-by: Carson Labrado <clabrado@google.com> Change-Id: Ic8369b0de8efb00ff168bc1ed43f1d7fd6c7366a
Diffstat (limited to 'http/http_client.hpp')
-rw-r--r--http/http_client.hpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/http/http_client.hpp b/http/http_client.hpp
index f59438be8c..c9526bbaf4 100644
--- a/http/http_client.hpp
+++ b/http/http_client.hpp
@@ -63,7 +63,6 @@ enum class ConnState
recvInProgress,
recvFailed,
idle,
- closeInProgress,
closed,
suspended,
terminated,
@@ -355,7 +354,6 @@ class ConnectionInfo : public std::enable_shared_from_this<ConnectionInfo>
void doClose()
{
- state = ConnState::closeInProgress;
boost::beast::error_code ec;
conn.socket().shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec);
conn.close();
@@ -366,18 +364,19 @@ class ConnectionInfo : public std::enable_shared_from_this<ConnectionInfo>
BMCWEB_LOG_ERROR << host << ":" << std::to_string(port)
<< ", id: " << std::to_string(connId)
<< "shutdown failed: " << ec.message();
- return;
}
- BMCWEB_LOG_DEBUG << host << ":" << std::to_string(port)
- << ", id: " << std::to_string(connId)
- << " closed gracefully";
+ else
+ {
+ BMCWEB_LOG_DEBUG << host << ":" << std::to_string(port)
+ << ", id: " << std::to_string(connId)
+ << " closed gracefully";
+ }
state = ConnState::closed;
}
void doCloseAndRetry()
{
- state = ConnState::closeInProgress;
boost::beast::error_code ec;
conn.socket().shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec);
conn.close();
@@ -388,11 +387,13 @@ class ConnectionInfo : public std::enable_shared_from_this<ConnectionInfo>
BMCWEB_LOG_ERROR << host << ":" << std::to_string(port)
<< ", id: " << std::to_string(connId)
<< "shutdown failed: " << ec.message();
- return;
}
- BMCWEB_LOG_DEBUG << host << ":" << std::to_string(port)
- << ", id: " << std::to_string(connId)
- << " closed gracefully";
+ else
+ {
+ BMCWEB_LOG_DEBUG << host << ":" << std::to_string(port)
+ << ", id: " << std::to_string(connId)
+ << " closed gracefully";
+ }
// Now let's try to resend the data
state = ConnState::retry;