]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: use new spawn() implementation
authorCasey Bodley <cbodley@redhat.com>
Wed, 6 Nov 2019 20:57:01 +0000 (15:57 -0500)
committerMauricio Faria de Oliveira <mfo@canonical.com>
Mon, 8 Mar 2021 12:36:37 +0000 (09:36 -0300)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 769841a08c3e79985d9634f06c9ff4d62647dcda)
Signed-off-by: Mauricio Faria de Oliveira <mfo@canonical.com>
Conflicts:
src/rgw/CMakeLists.txt
- Remove changes for 'rgw_schedulers' cmake target, not in Nautilus.
- Link 'radosgw_a' against 'spawn'; transitivity from 'rgw_schedulers'
  (which is public) is lost, and 'rgw_a'/'rgw_libs' (which is private
  to 'radosgw_a') isn't enough to build 'rgw_main.cc' ( error below.)
src/rgw/rgw_aio.cc
- This file doesn't exist in Nautilus; similar changes are done in
  other files.
src/rgw/rgw_aio_throttle.h
- No changes required; the base for the changes (e.g., class, variables)
  are not in Nautilus.
src/rgw/rgw_asio_frontend.cc
- Less changes required, similarly; commit dd4350b not in Nautilus.

Build error:

  In file included from /git/ceph/src/rgw/rgw_common.h:31:0,
                   from /git/ceph/src/rgw/rgw_main.cc:15:
  /git/ceph/src/common/async/yield_context.h:31:10: fatal error: spawn/spawn.hpp: No such file or directory
   #include <spawn/spawn.hpp>
            ^~~~~~~~~~~~~~~~~
  compilation terminated.
  src/rgw/CMakeFiles/radosgw.dir/build.make:62: recipe for target 'src/rgw/CMakeFiles/radosgw.dir/rgw_main.cc.o' failed

src/common/async/yield_context.h
src/rgw/CMakeLists.txt
src/rgw/rgw_asio_frontend.cc

index 436192c02f7d7f391661d279675b47e3167d2b55..fdfb3f5b8fe1a4586981c239af5a4df0f15975b0 100644 (file)
 
 #ifndef HAVE_BOOST_CONTEXT
 
-// hide the dependencies on boost::context and boost::coroutines
-namespace boost::asio {
+// hide the dependency on boost::context
+namespace spawn {
 struct yield_context;
 }
 
 #else // HAVE_BOOST_CONTEXT
-#ifndef BOOST_COROUTINES_NO_DEPRECATION_WARNING
-#define BOOST_COROUTINES_NO_DEPRECATION_WARNING
-#endif
-#include <boost/asio/spawn.hpp>
+#include <spawn/spawn.hpp>
 
 #endif // HAVE_BOOST_CONTEXT
 
 
-/// optional-like wrapper for a boost::asio::yield_context and its associated
+/// optional-like wrapper for a spawn::yield_context and its associated
 /// boost::asio::io_context. operations that take an optional_yield argument
 /// will, when passed a non-empty yield context, suspend this coroutine instead
 /// of the blocking the thread of execution
 class optional_yield {
   boost::asio::io_context *c = nullptr;
-  boost::asio::yield_context *y = nullptr;
+  spawn::yield_context *y = nullptr;
  public:
   /// construct with a valid io and yield_context
   explicit optional_yield(boost::asio::io_context& c,
-                          boost::asio::yield_context& y) noexcept
+                          spawn::yield_context& y) noexcept
     : c(&c), y(&y) {}
 
   /// type tag to construct an empty object
@@ -60,7 +57,7 @@ class optional_yield {
   boost::asio::io_context& get_io_context() const noexcept { return *c; }
 
   /// return a reference to the yield_context. only valid if non-empty
-  boost::asio::yield_context& get_yield_context() const noexcept { return *y; }
+  spawn::yield_context& get_yield_context() const noexcept { return *y; }
 };
 
 // type tag object to construct an empty optional_yield
index b1c757d60fa7f4268cbbb714ada88ffa2dab4ec3..009e0a2bcbf04156ee3e03ddcfb0831384720e39 100644 (file)
@@ -151,6 +151,10 @@ add_library(rgw_common OBJECT ${librgw_common_srcs})
 target_include_directories(rgw_common SYSTEM PUBLIC "services")
 target_include_directories(rgw_common PUBLIC "${CMAKE_SOURCE_DIR}/src/dmclock/support/src")
 
+if(WITH_BOOST_CONTEXT)
+  target_link_libraries(rgw_common PUBLIC spawn)
+endif()
+
 if(WITH_LTTNG)
   # rgw/rgw_op.cc includes "tracing/rgw_op.h"
   # rgw/rgw_rados.cc includes "tracing/rgw_rados.h"
@@ -219,7 +223,7 @@ if(WITH_CURL_OPENSSL)
 endif()
 
 if(WITH_BOOST_CONTEXT)
-  target_link_libraries(rgw_a PRIVATE spawn)
+  target_link_libraries(rgw_a PUBLIC spawn)
 endif()
 
 set(rgw_libs rgw_a)
@@ -258,6 +262,9 @@ if(WITH_RADOSGW_BEAST_FRONTEND AND WITH_RADOSGW_BEAST_OPENSSL)
   # used by rgw_asio_frontend.cc
   target_link_libraries(radosgw_a PRIVATE OpenSSL::SSL)
 endif()
+if(WITH_BOOST_CONTEXT)
+  target_link_libraries(radosgw_a PUBLIC spawn)
+endif()
 
 add_executable(radosgw rgw_main.cc)
 target_link_libraries(radosgw radosgw_a librados
@@ -380,9 +387,6 @@ endif()
 if(WITH_RADOSGW_KAFKA_ENDPOINT)
   target_link_libraries(rgw_admin_user PRIVATE RDKafka::RDKafka)
 endif()
-if(WITH_BOOST_CONTEXT)
-  target_link_libraries(rgw_admin_user PRIVATE Boost::coroutine Boost::context)
-endif()
 
 if(WITH_TESTS)
   add_executable(ceph_rgw_jsonparser
index 10e8d35a555962e2e6b93f84edb595a8d7a21c57..5b59d17ef6661bc80cef3c056cf42a50b048ebd8 100644 (file)
@@ -6,12 +6,10 @@
 #include <vector>
 
 #include <boost/asio.hpp>
-#define BOOST_COROUTINES_NO_DEPRECATION_WARNING
-#include <boost/range/begin.hpp>
-#include <boost/range/end.hpp>
-#include <boost/asio/spawn.hpp>
 #include <boost/intrusive/list.hpp>
 
+#include <spawn/spawn.hpp>
+
 #include "common/async/shared_mutex.h"
 #include "common/errno.h"
 #include "common/strtol.h"
@@ -123,7 +121,7 @@ void handle_connection(boost::asio::io_context& context,
                        SharedMutex& pause_mutex,
                        rgw::dmclock::Scheduler *scheduler,
                        boost::system::error_code& ec,
-                       boost::asio::yield_context yield)
+                       spawn::yield_context yield)
 {
   // limit header to 4k, since we read it all into a single flat_buffer
   static constexpr size_t header_limit = 4096;
@@ -649,8 +647,8 @@ void AsioFrontend::accept(Listener& l, boost::system::error_code ec)
   // spawn a coroutine to handle the connection
 #ifdef WITH_RADOSGW_BEAST_OPENSSL
   if (l.use_ssl) {
-    boost::asio::spawn(context,
-      [this, s=std::move(socket)] (boost::asio::yield_context yield) mutable {
+    spawn::spawn(context,
+      [this, s=std::move(socket)] (spawn::yield_context yield) mutable {
         Connection conn{s};
         auto c = connections.add(conn);
         // wrap the socket in an ssl stream
@@ -677,8 +675,8 @@ void AsioFrontend::accept(Listener& l, boost::system::error_code ec)
 #else
   {
 #endif // WITH_RADOSGW_BEAST_OPENSSL
-    boost::asio::spawn(context,
-      [this, s=std::move(socket)] (boost::asio::yield_context yield) mutable {
+    spawn::spawn(context,
+      [this, s=std::move(socket)] (spawn::yield_context yield) mutable {
         Connection conn{s};
         auto c = connections.add(conn);
         auto buffer = std::make_unique<parse_buffer>();