Skip to content

Commit

Permalink
IfwApiCheckTask: Use AsioTlsStream::GracefulDisconnect()
Browse files Browse the repository at this point in the history
  • Loading branch information
julianbrost committed Feb 16, 2024
1 parent d6953cc commit e90acc5
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions lib/methods/ifwapichecktask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ static const char* GetUnderstandableError(const std::exception& ex)
}

static void DoIfwNetIo(
boost::asio::yield_context yc, const Checkable::Ptr& checkable, const Array::Ptr& cmdLine,
boost::asio::yield_context yc, boost::asio::io_context::strand& strand, const Checkable::Ptr& checkable, const Array::Ptr& cmdLine,
const CheckResult::Ptr& cr, const String& psCommand, const String& psHost, const String& san, const String& psPort,
AsioTlsStream& conn, boost::beast::http::request<boost::beast::http::string_body>& req, double start
const AsioTlsStream::Ptr& conn, boost::beast::http::request<boost::beast::http::string_body>& req, double start
)
{
namespace http = boost::beast::http;
Expand All @@ -105,7 +105,7 @@ static void DoIfwNetIo(
http::response<http::string_body> resp;

try {
Connect(conn.lowest_layer(), psHost, psPort, yc);
Connect(conn->lowest_layer(), psHost, psPort, yc);
} catch (const std::exception& ex) {
ReportIfwCheckResult(
yc, checkable, cmdLine, cr,
Expand All @@ -115,10 +115,10 @@ static void DoIfwNetIo(
return;
}

auto& sslConn (conn.next_layer());
auto& sslConn (conn->next_layer());

try {
sslConn.async_handshake(conn.next_layer().client, yc);
sslConn.async_handshake(conn->next_layer().client, yc);
} catch (const std::exception& ex) {
ReportIfwCheckResult(
yc, checkable, cmdLine, cr,
Expand Down Expand Up @@ -148,8 +148,8 @@ static void DoIfwNetIo(
}

try {
http::async_write(conn, req, yc);
conn.async_flush(yc);
http::async_write(*conn, req, yc);
conn->async_flush(yc);
} catch (const std::exception& ex) {
ReportIfwCheckResult(
yc, checkable, cmdLine, cr,
Expand All @@ -160,7 +160,7 @@ static void DoIfwNetIo(
}

try {
http::async_read(conn, buf, resp, yc);
http::async_read(*conn, buf, resp, yc);
} catch (const std::exception& ex) {
ReportIfwCheckResult(
yc, checkable, cmdLine, cr,
Expand All @@ -172,10 +172,7 @@ static void DoIfwNetIo(

double end = Utility::GetTime();

{
boost::system::error_code ec;
sslConn.async_shutdown(yc[ec]);
}
conn->GracefulDisconnect(strand, yc);

CpuBoundWork cbw (yc);
Value jsonRoot;
Expand Down Expand Up @@ -525,7 +522,7 @@ void IfwApiCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes

Defer cancelTimeout ([&timeout]() { timeout->Cancel(); });

DoIfwNetIo(yc, checkable, cmdLine, cr, psCommand, psHost, expectedSan, psPort, *conn, *req, start);
DoIfwNetIo(yc, *strand, checkable, cmdLine, cr, psCommand, psHost, expectedSan, psPort, conn, *req, start);
}
);
}

0 comments on commit e90acc5

Please sign in to comment.