mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-02 04:22:03 +00:00
Fix possible terminate called for uncaught exception in Connection
This commit is contained in:
parent
c2f240b8ee
commit
029c92344b
@ -232,12 +232,27 @@ void Connection::disconnect()
|
|||||||
maybe_compressed_out = nullptr;
|
maybe_compressed_out = nullptr;
|
||||||
in = nullptr;
|
in = nullptr;
|
||||||
last_input_packet_type.reset();
|
last_input_packet_type.reset();
|
||||||
out = nullptr; // can write to socket
|
std::exception_ptr finalize_exception;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// finalize() can write to socket and throw an exception.
|
||||||
|
out->finalize();
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
/// Don't throw an exception here, it will leave Connection in invalid state.
|
||||||
|
finalize_exception = std::current_exception();
|
||||||
|
}
|
||||||
|
out = nullptr;
|
||||||
|
|
||||||
if (socket)
|
if (socket)
|
||||||
socket->close();
|
socket->close();
|
||||||
socket = nullptr;
|
socket = nullptr;
|
||||||
connected = false;
|
connected = false;
|
||||||
nonce.reset();
|
nonce.reset();
|
||||||
|
|
||||||
|
if (finalize_exception)
|
||||||
|
std::rethrow_exception(finalize_exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user