Skip to content

Commit e90acc5

Browse files
committed
IfwApiCheckTask: Use AsioTlsStream::GracefulDisconnect()
1 parent d6953cc commit e90acc5

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

lib/methods/ifwapichecktask.cpp

+10-13
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ static const char* GetUnderstandableError(const std::exception& ex)
9494
}
9595

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

107107
try {
108-
Connect(conn.lowest_layer(), psHost, psPort, yc);
108+
Connect(conn->lowest_layer(), psHost, psPort, yc);
109109
} catch (const std::exception& ex) {
110110
ReportIfwCheckResult(
111111
yc, checkable, cmdLine, cr,
@@ -115,10 +115,10 @@ static void DoIfwNetIo(
115115
return;
116116
}
117117

118-
auto& sslConn (conn.next_layer());
118+
auto& sslConn (conn->next_layer());
119119

120120
try {
121-
sslConn.async_handshake(conn.next_layer().client, yc);
121+
sslConn.async_handshake(conn->next_layer().client, yc);
122122
} catch (const std::exception& ex) {
123123
ReportIfwCheckResult(
124124
yc, checkable, cmdLine, cr,
@@ -148,8 +148,8 @@ static void DoIfwNetIo(
148148
}
149149

150150
try {
151-
http::async_write(conn, req, yc);
152-
conn.async_flush(yc);
151+
http::async_write(*conn, req, yc);
152+
conn->async_flush(yc);
153153
} catch (const std::exception& ex) {
154154
ReportIfwCheckResult(
155155
yc, checkable, cmdLine, cr,
@@ -160,7 +160,7 @@ static void DoIfwNetIo(
160160
}
161161

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

173173
double end = Utility::GetTime();
174174

175-
{
176-
boost::system::error_code ec;
177-
sslConn.async_shutdown(yc[ec]);
178-
}
175+
conn->GracefulDisconnect(strand, yc);
179176

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

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

528-
DoIfwNetIo(yc, checkable, cmdLine, cr, psCommand, psHost, expectedSan, psPort, *conn, *req, start);
525+
DoIfwNetIo(yc, *strand, checkable, cmdLine, cr, psCommand, psHost, expectedSan, psPort, conn, *req, start);
529526
}
530527
);
531528
}

0 commit comments

Comments
 (0)