close_statement.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // Copyright (c) 2019-2025 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. #ifndef BOOST_MYSQL_IMPL_INTERNAL_SANSIO_CLOSE_STATEMENT_HPP
  8. #define BOOST_MYSQL_IMPL_INTERNAL_SANSIO_CLOSE_STATEMENT_HPP
  9. #include <boost/mysql/detail/algo_params.hpp>
  10. #include <boost/mysql/detail/pipeline.hpp>
  11. #include <boost/mysql/impl/internal/protocol/serialization.hpp>
  12. #include <boost/mysql/impl/internal/sansio/connection_state_data.hpp>
  13. namespace boost {
  14. namespace mysql {
  15. namespace detail {
  16. inline run_pipeline_algo_params setup_close_statement_pipeline(
  17. connection_state_data& st,
  18. close_statement_algo_params params
  19. )
  20. {
  21. // Pipeline a ping with the close statement, to avoid delays on old connections
  22. // that don't set tcp_nodelay. Both requests are small and fixed size, so
  23. // we don't enforce any buffer limits here.
  24. st.write_buffer.clear();
  25. auto seqnum1 = serialize_top_level_checked(close_stmt_command{params.stmt_id}, st.write_buffer);
  26. auto seqnum2 = serialize_top_level_checked(ping_command{}, st.write_buffer);
  27. st.shared_pipeline_stages = {
  28. {
  29. {pipeline_stage_kind::close_statement, seqnum1, {}},
  30. {pipeline_stage_kind::ping, seqnum2, {}},
  31. }
  32. };
  33. return {st.write_buffer, st.shared_pipeline_stages, nullptr};
  34. }
  35. } // namespace detail
  36. } // namespace mysql
  37. } // namespace boost
  38. #endif