File indexing completed on 2025-09-18 08:52:42
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_MYSQL_IMPL_INTERNAL_SANSIO_QUIT_CONNECTION_HPP
0009 #define BOOST_MYSQL_IMPL_INTERNAL_SANSIO_QUIT_CONNECTION_HPP
0010
0011 #include <boost/mysql/diagnostics.hpp>
0012 #include <boost/mysql/error_code.hpp>
0013
0014 #include <boost/mysql/detail/algo_params.hpp>
0015 #include <boost/mysql/detail/next_action.hpp>
0016
0017 #include <boost/mysql/impl/internal/coroutine.hpp>
0018 #include <boost/mysql/impl/internal/protocol/serialization.hpp>
0019 #include <boost/mysql/impl/internal/sansio/connection_state_data.hpp>
0020
0021 namespace boost {
0022 namespace mysql {
0023 namespace detail {
0024
0025 class quit_connection_algo
0026 {
0027 int resume_point_{0};
0028 std::uint8_t sequence_number_{0};
0029 bool should_perform_shutdown_{};
0030
0031 public:
0032 quit_connection_algo(quit_connection_algo_params) noexcept {}
0033
0034 next_action resume(connection_state_data& st, diagnostics&, error_code ec)
0035 {
0036 switch (resume_point_)
0037 {
0038 case 0:
0039
0040
0041
0042
0043 should_perform_shutdown_ = st.tls_active;
0044 st.status = connection_status::not_connected;
0045 st.tls_active = false;
0046
0047
0048 BOOST_MYSQL_YIELD(resume_point_, 1, st.write(quit_command(), sequence_number_))
0049 if (ec)
0050 return ec;
0051
0052
0053
0054
0055 if (should_perform_shutdown_)
0056 {
0057 BOOST_MYSQL_YIELD(resume_point_, 2, next_action::ssl_shutdown())
0058 }
0059 }
0060
0061 return next_action();
0062 }
0063 };
0064
0065 }
0066 }
0067 }
0068
0069 #endif