]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix compilation with older boost versions that don't have asio coroutines
authorOrit Wasserman <owasserm@redhat.com>
Mon, 9 Nov 2015 10:59:22 +0000 (11:59 +0100)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 12 Feb 2016 00:13:30 +0000 (16:13 -0800)
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
CMakeLists.txt
configure.ac
src/CMakeLists.txt
src/rgw/Makefile.am
src/rgw/rgw_boost_asio_coroutine.h [new file with mode: 0644]
src/rgw/rgw_boost_asio_yield.h [new file with mode: 0644]
src/rgw/rgw_coroutine.cc
src/rgw/rgw_coroutine.h
src/rgw/rgw_cr_rados.cc
src/rgw/rgw_data_sync.cc
src/rgw/rgw_sync.cc

index 65282030af5e79ed8005f466d0aec59c5837e5da..413243b68c7e27d1a79089d2f574e9426b3caebd 100644 (file)
@@ -48,6 +48,7 @@ CHECK_FUNCTION_EXISTS(mallinfo HAVE_MALLINFO)
 CHECK_FUNCTION_EXISTS(pwritev HAVE_PWRITEV)
 CHECK_INCLUDE_FILES("arpa/inet.h" HAVE_ARPA_INET_H)
 CHECK_INCLUDE_FILES("boost/random/discrete_distribution.hpp" HAVE_BOOST_RANDOM_DISCRETE_DISTRIBUTION)
+CHECK_INCLUDE_FILE_CXX("boost/asio/coroutine.hpp" HAVE_BOOST_ASIO_COROUTINE)
 CHECK_INCLUDE_FILES("dirent.h" HAVE_DIRENT_H)
 CHECK_INCLUDE_FILES("dlfcn.h" HAVE_DLFCN_H)
 CHECK_INCLUDE_FILES("inttypes.h" HAVE_INTTYPES_H)
index 09d9f64231cc56b9d9674bddd2414b47af672ec1..62ef1b1f113a45206bbf89000c3af2a0ae147a80 100644 (file)
@@ -915,6 +915,9 @@ AC_CHECK_HEADER([boost/random/discrete_distribution.hpp],
        [AC_DEFINE([HAVE_BOOST_RANDOM_DISCRETE_DISTRIBUTION], [], [have boost::random::discrete_distribution])],
        [])
 
+AC_CHECK_HEADER([boost/asio/coroutine.hpp],
+       [AC_DEFINE([HAVE_BOOST_ASIO_COROUTINE], [], [have boost::asio::coroutine])],
+       [])
 AC_CHECK_HEADER([boost/statechart/state.hpp], [],
     AC_MSG_FAILURE(["Can't find boost statechart headers; need 1.34 or later"]))
 AC_CHECK_HEADER([boost/regex.hpp], [],
index 52bfc4a152c18eed4e23fa0d32d5c24ed9b1c9fc..9e71f43a204f22b57635506572c2933da4d31e04 100644 (file)
@@ -1182,6 +1182,10 @@ if(${WITH_RADOSGW})
     cls_log_client cls_statelog_client cls_timeindex_client cls_version_client
     cls_replica_log_client cls_user_client curl global expat)
 
+  if(HAVE_BOOST_ASIO_COROUTINE)
+    target_compile_definitions(rgw_a PUBLIC "HAVE_BOOST_ASIO_COROUTINE")
+  endif()
+
   set(radosgw_srcs
     rgw/rgw_resolve.cc
     rgw/rgw_rest.cc
@@ -1232,6 +1236,7 @@ if(${WITH_RADOSGW})
     cls_log_client cls_statelog_client cls_timeindex_client
     cls_version_client cls_replica_log_client cls_user_client
     curl expat global fcgi resolv ${BLKID_LIBRARIES} ${ALLOC_LIBS})
+
   install(TARGETS radosgw-admin DESTINATION bin)
 
   add_executable(radosgw-object-expirer ${radosgw_object_expirer_srcs} $<TARGET_OBJECTS:heap_profiler_objs>)
index 32f34311ba93b383e125af8fa9ae4c5311d50804..8d7816b4915554c273a9f3fd9c688303885e2ec5 100644 (file)
@@ -203,6 +203,8 @@ noinst_HEADERS += \
        rgw/rgw_keystone.h \
        rgw/rgw_realm_watcher.h \
        rgw/rgw_civetweb.h \
+       rgw/rgw_boost_asio_coroutine.h \
+       rgw/rgw_boost_asio_yield.h \
        rgw/rgw_civetweb_log.h \
        rgw/rgw_website.h \
        rgw/rgw_rest_s3website.h \
diff --git a/src/rgw/rgw_boost_asio_coroutine.h b/src/rgw/rgw_boost_asio_coroutine.h
new file mode 100644 (file)
index 0000000..2dd911e
--- /dev/null
@@ -0,0 +1,67 @@
+//
+// copy of needed class and macors from coroutine.hpp
+//
+// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#ifndef RGW_BOOST_ASIO_COROUTINE_H
+#define RGW_BOOST_ASIO_COROUTINE_H
+
+#ifndef HAVE_BOOST_ASIO_COROUTINE
+
+namespace boost {
+namespace asio {
+namespace detail {
+
+class coroutine_ref;
+
+} // namespace detail
+
+class coroutine
+{
+public:
+  /// Constructs a coroutine in its initial state.
+  coroutine() : value_(0) {}
+
+  /// Returns true if the coroutine is the child of a fork.
+  bool is_child() const { return value_ < 0; }
+
+  /// Returns true if the coroutine is the parent of a fork.
+  bool is_parent() const { return !is_child(); }
+
+  /// Returns true if the coroutine has reached its terminal state.
+  bool is_complete() const { return value_ == -1; }
+
+private:
+  friend class detail::coroutine_ref;
+  int value_;
+};
+
+
+namespace detail {
+
+class coroutine_ref
+{
+public:
+  coroutine_ref(coroutine& c) : value_(c.value_), modified_(false) {}
+  coroutine_ref(coroutine* c) : value_(c->value_), modified_(false) {}
+  ~coroutine_ref() { if (!modified_) value_ = -1; }
+  operator int() const { return value_; }
+  int& operator=(int v) { modified_ = true; return value_ = v; }
+private:
+  void operator=(const coroutine_ref&);
+  int& value_;
+  bool modified_;
+};
+
+} // namespace detail
+} // namespace asio
+} // namespace boost
+
+#endif // HAVE_BOOST_ASIO_COROUTINE
+
+#endif // RGW_BOOST_ASIO_COROUTINE_H
+
diff --git a/src/rgw/rgw_boost_asio_yield.h b/src/rgw/rgw_boost_asio_yield.h
new file mode 100644 (file)
index 0000000..aeb9321
--- /dev/null
@@ -0,0 +1,78 @@
+//
+// copy of needed macors from yield.hpp
+//
+// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#ifndef RGW_BOOST_ASIO_YIELD_H
+#define RGW_BOOST_ASIO_YIELD_H
+
+#ifdef HAVE_BOOST_ASIO_COROUTINE
+#include <boost/asio/yield.hpp>
+#else
+#define BOOST_ASIO_CORO_REENTER(c) \
+  switch (::boost::asio::detail::coroutine_ref _coro_value = c) \
+    case -1: if (_coro_value) \
+    { \
+      goto terminate_coroutine; \
+      terminate_coroutine: \
+      _coro_value = -1; \
+      goto bail_out_of_coroutine; \
+      bail_out_of_coroutine: \
+      break; \
+    } \
+    else case 0:
+
+#define BOOST_ASIO_CORO_YIELD_IMPL(n) \
+  for (_coro_value = (n);;) \
+    if (_coro_value == 0) \
+    { \
+      case (n): ; \
+      break; \
+    } \
+    else \
+      switch (_coro_value ? 0 : 1) \
+        for (;;) \
+          case -1: if (_coro_value) \
+            goto terminate_coroutine; \
+          else for (;;) \
+            case 1: if (_coro_value) \
+              goto bail_out_of_coroutine; \
+            else case 0:
+
+#define BOOST_ASIO_CORO_FORK_IMPL(n) \
+  for (_coro_value = -(n);; _coro_value = (n)) \
+    if (_coro_value == (n)) \
+    { \
+      case -(n): ; \
+      break; \
+    } \
+    else
+
+#if defined(_MSC_VER)
+# define BOOST_ASIO_CORO_YIELD BOOST_ASIO_CORO_YIELD_IMPL(__COUNTER__ + 1)
+# define BOOST_ASIO_CORO_FORK BOOST_ASIO_CORO_FORK_IMPL(__COUNTER__ + 1)
+#else // defined(_MSC_VER)
+# define BOOST_ASIO_CORO_YIELD BOOST_ASIO_CORO_YIELD_IMPL(__LINE__)
+# define BOOST_ASIO_CORO_FORK BOOST_ASIO_CORO_FORK_IMPL(__LINE__)
+#endif // defined(_MSC_VER)
+
+#ifndef reenter
+# define reenter(c) BOOST_ASIO_CORO_REENTER(c)
+#endif
+
+#ifndef yield
+# define yield BOOST_ASIO_CORO_YIELD
+#endif
+
+#ifndef fork
+# define fork BOOST_ASIO_CORO_FORK
+#endif
+
+#endif // HAVE_BOOST_ASIO_COROUTINE
+
+#endif // RGW_BOOST_ASIO_YIELD_H
+
index 1459524a12cab0cfe76672a8354f1e2bba72ac62..eaac0ef13845df65bf14ffcfe99adf2b2a2eb202 100644 (file)
@@ -1,8 +1,8 @@
 
 
 #include "rgw_coroutine.h"
+#include "rgw_boost_asio_yield.h"
 
-#include <boost/asio/yield.hpp>
 
 #define dout_subsys ceph_subsys_rgw
 
index 2c90629aafb70def6afb3c40f6507f27e9fc3bd1..24d38cc0050cc98bf6fa94e94752bd67b885e991 100644 (file)
@@ -18,6 +18,7 @@
 #include "common/Timer.h"
 
 #include "rgw_common.h"
+#include "rgw_boost_asio_coroutine.h"
 
 #define RGW_ASYNC_OPS_MGR_WINDOW 100
 
@@ -125,6 +126,7 @@ struct rgw_spawned_stacks {
 };
 
 
+
 class RGWCoroutine : public RefCountedObject, public boost::asio::coroutine {
   friend class RGWCoroutinesStack;
 
index 030829fc511ea655ba381f5425f6bcca328d3dd8..9ffefdac5e59d7cca55c3c38a7167acaf116fde0 100644 (file)
@@ -1,12 +1,10 @@
 #include "rgw_rados.h"
 #include "rgw_coroutine.h"
+#include "rgw_boost_asio_yield.h"
 #include "rgw_cr_rados.h"
 
 #include "cls/lock/cls_lock_client.h"
 
-#include <boost/asio/yield.hpp>
-
-
 #define dout_subsys ceph_subsys_rgw
 
 bool RGWAsyncRadosProcessor::RGWWQ::_enqueue(RGWAsyncRadosRequest *req) {
index c23845d57a09d6814a91c68ef138d0d7404006e5..f5fa262aced9bed143659b74f7ce1f54037a47d5 100644 (file)
 #include "rgw_http_client.h"
 #include "rgw_bucket.h"
 #include "rgw_metadata.h"
+#include "rgw_boost_asio_yield.h"
 
 #include "cls/lock/cls_lock_client.h"
 
-#include <boost/asio/yield.hpp>
-
-
 #define dout_subsys ceph_subsys_rgw
 
 static string datalog_sync_status_oid_prefix = "datalog.sync-status";
index 71504e78a894d90e5fa679301dfcde081e059844..49ddd98b893a2d34b0cb32d8ac2ac21a56d14420 100644 (file)
 #include "rgw_cr_rados.h"
 #include "rgw_cr_rest.h"
 #include "rgw_http_client.h"
+#include "rgw_boost_asio_yield.h"
 
 #include "cls/lock/cls_lock_client.h"
 
-#include <boost/asio/yield.hpp>
-
-
 #define dout_subsys ceph_subsys_rgw
 
 static string mdlog_sync_status_oid = "mdlog.sync-status";