add close_reason parameter to quic::Endpoint::close_connection defaulting to emtpy string

pull/1846/head
Jeff 2 years ago
parent 95efe8f4e5
commit 582fdeda27

@ -225,7 +225,8 @@ namespace llarp::quic
}
void
Endpoint::close_connection(Connection& conn, uint64_t code, bool application)
Endpoint::close_connection(
Connection& conn, uint64_t code, bool application, std::string_view close_reason)
{
LogDebug("Closing connection ", conn.base_cid);
if (!conn.closing)
@ -245,8 +246,8 @@ namespace llarp::quic
u8data(conn.conn_buffer),
conn.conn_buffer.size(),
code,
nullptr, // reason
0, // reason length
reinterpret_cast<const uint8_t*>(close_reason.data()),
close_reason.size(),
get_timestamp());
if (written <= 0)
{

@ -200,10 +200,16 @@ namespace llarp::quic
//
// Takes the iterator to the connection pair from `conns` and optional error parameters: if
// `application` is false (the default) then we do a hard connection close because of transport
// error, if true we do a graceful application close. For application closes the code is
// application-defined; for hard closes the code should be one of the NGTCP2_*_ERROR values.
// error, if true we do a graceful application close. `close_reason` can be provided for
// propagating reason for close to remote, defaults to empty string. For application closes the
// code is application-defined; for hard closes the code should be one of the NGTCP2_*_ERROR
// values.
void
close_connection(Connection& conn, uint64_t code = NGTCP2_NO_ERROR, bool application = false);
close_connection(
Connection& conn,
uint64_t code = NGTCP2_NO_ERROR,
bool application = false,
std::string_view close_reason = ""sv);
/// Puts a connection into draining mode (i.e. after getting a connection close). This will
/// keep the connection registered for the recommended 3*Probe Timeout, during which we drop

Loading…
Cancel
Save