File indexing completed on 2025-12-13 09:54:57
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_MYSQL_IMPL_INTERNAL_SANSIO_CLOSE_CONNECTION_HPP
0009 #define BOOST_MYSQL_IMPL_INTERNAL_SANSIO_CLOSE_CONNECTION_HPP
0010
0011 #include <boost/mysql/diagnostics.hpp>
0012
0013 #include <boost/mysql/detail/algo_params.hpp>
0014 #include <boost/mysql/detail/next_action.hpp>
0015
0016 #include <boost/mysql/impl/internal/coroutine.hpp>
0017 #include <boost/mysql/impl/internal/sansio/connection_state_data.hpp>
0018 #include <boost/mysql/impl/internal/sansio/quit_connection.hpp>
0019
0020 namespace boost {
0021 namespace mysql {
0022 namespace detail {
0023
0024 class close_connection_algo
0025 {
0026 int resume_point_{0};
0027 quit_connection_algo quit_{{}};
0028 error_code stored_ec_;
0029
0030 public:
0031 close_connection_algo(close_connection_algo_params) noexcept {}
0032
0033 next_action resume(connection_state_data& st, diagnostics& diag, error_code ec)
0034 {
0035 next_action act;
0036
0037 switch (resume_point_)
0038 {
0039 case 0:
0040
0041
0042
0043 if (st.status == connection_status::not_connected)
0044 return next_action();
0045
0046
0047 while (!(act = quit_.resume(st, diag, ec)).is_done())
0048 BOOST_MYSQL_YIELD(resume_point_, 1, act)
0049 stored_ec_ = act.error();
0050
0051
0052 BOOST_MYSQL_YIELD(resume_point_, 2, next_action::close())
0053
0054
0055
0056 if (stored_ec_)
0057 ec = stored_ec_;
0058 }
0059
0060 return ec;
0061 }
0062 };
0063
0064 }
0065 }
0066 }
0067
0068 #endif