File indexing completed on 2025-04-19 08:33:52
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 diagnostics* diag_;
0029 std::uint8_t sequence_number_{0};
0030
0031 public:
0032 quit_connection_algo(quit_connection_algo_params params) noexcept : diag_(params.diag) {}
0033
0034 diagnostics& diag() { return *diag_; }
0035
0036 next_action resume(connection_state_data& st, error_code ec)
0037 {
0038 switch (resume_point_)
0039 {
0040 case 0:
0041
0042
0043 diag_->clear();
0044
0045
0046 BOOST_MYSQL_YIELD(resume_point_, 1, st.write(quit_command(), sequence_number_))
0047
0048
0049 st.is_connected = false;
0050
0051
0052 if (ec)
0053 return ec;
0054
0055
0056 if (st.ssl == ssl_state::active)
0057 {
0058 BOOST_MYSQL_YIELD(resume_point_, 2, next_action::ssl_shutdown())
0059 st.ssl = ssl_state::torn_down;
0060 }
0061
0062
0063 }
0064
0065 return next_action();
0066 }
0067 };
0068
0069 }
0070 }
0071 }
0072
0073 #endif