resend terminal disconnect

Summary:
- if we are in the process of connecting when user invokes async_disconnect we should send a disconnect packet after connect completes
- move integration disconnect tests to integration folder

Reviewers: ivica

Reviewed By: ivica

Subscribers: korina

Differential Revision: https://repo.mireo.local/D28119
This commit is contained in:
Bruno Iljazovic
2024-02-23 14:38:57 +01:00
parent 2f055e8894
commit 701698e5ec
4 changed files with 319 additions and 236 deletions

View File

@@ -98,14 +98,17 @@ public:
_svc_ptr->async_send(
wire_data,
no_serial, send_flag::terminal,
asio::consign(
asio::prepend(std::move(*this), on_disconnect {}),
std::move(disconnect)
asio::prepend(
std::move(*this),
on_disconnect {}, std::move(disconnect)
)
);
}
void operator()(on_disconnect, error_code ec) {
void operator()(
on_disconnect,
control_packet<allocator_type> disconnect, error_code ec
) {
// The connection must be closed even
// if we failed to send the DISCONNECT packet
// with Reason Code of 0x80 or greater.
@@ -116,14 +119,17 @@ public:
)
return complete(asio::error::operation_aborted);
if (ec == asio::error::try_again) {
if (_context.terminal)
return send_disconnect(std::move(disconnect));
return complete(error_code {});
}
if (_context.terminal) {
_svc_ptr->cancel();
return complete(error_code {});
}
if (ec == asio::error::try_again)
return complete(error_code {});
_svc_ptr->close_stream();
_svc_ptr->open_stream();

View File

@@ -872,8 +872,8 @@ public:
*
* \par Completion condition
* The asynchronous operation will complete when one of the following conditions is true:\n
* - The Client has attempted to send a \__DISCONNECT\__ packet, regardless of whether
* the sending was successful or not.\n
* - The Client has sent a \__DISCONNECT\__ packet.\n
* - 5 seconds have elapsed without a successful send.\n
* - An error occurred. This is indicated by an associated \__ERROR_CODE\__ in the handler.\n
*
* \par Error codes