]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
buffer: make buffer::exception classes undefined in dynamic objects
authorYan, Zheng <zyan@redhat.com>
Wed, 29 Jul 2015 09:44:52 +0000 (17:44 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 31 Aug 2015 08:00:26 +0000 (16:00 +0800)
On OSX, if the an exception class is declared and defined in header file,
but it ends up being compiled as private symbols in different binaries.
The exception handling code will take the two compiled exception classes
as different types! In our case, the one in libcls_xxx.so and the one is
ceph-osd are considered as different classes, thus the try-catch statement
fails to work.

The fix is force buffer::exception classes undefined in libcls_xxx.so. The
ibcls_xxx.so are compiled with '-undefined dynamic_lookup' option. when
it is loaded into ceph-osd, buffer::exception classes in ceph-osd will be
used.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/common/buffer.cc
src/include/buffer.h

index 27dc62a19e5fc4cdce69317f4bfd6e415572038f..1ab62241f9c061e543406baf678fa3bf672f1ffa 100644 (file)
@@ -120,6 +120,18 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER;
     return 65536;
   }
 
+  const char * buffer::error::what() const throw () {
+    return "buffer::exception";
+  }
+  const char * buffer::bad_alloc::what() const throw () {
+    return "buffer::bad_alloc";
+  }
+  const char * buffer::end_of_buffer::what() const throw () {
+    return "buffer::end_of_buffer";
+  }
+  const char * buffer::malformed_input::what() const throw () {
+    return buf;
+  }
   buffer::error_code::error_code(int error) :
     buffer::malformed_input(cpp_strerror(error).c_str()), code(error) {}
 
index a54befa11c8a3dcdb6013b95e0464255139ace6a..bb6ea9356c537c71691906dc0382c580aa832001 100644 (file)
@@ -75,27 +75,19 @@ class CEPH_BUFFER_API buffer {
 
 public:
   struct error : public std::exception{
-    const char *what() const throw () {
-      return "buffer::exception";
-    }
+    const char *what() const throw ();
   };
   struct bad_alloc : public error {
-    const char *what() const throw () {
-      return "buffer::bad_alloc";
-    }
+    const char *what() const throw ();
   };
   struct end_of_buffer : public error {
-    const char *what() const throw () {
-      return "buffer::end_of_buffer";
-    }
+    const char *what() const throw ();
   };
   struct malformed_input : public error {
     explicit malformed_input(const std::string& w) {
       snprintf(buf, sizeof(buf), "buffer::malformed_input: %s", w.c_str());
     }
-    const char *what() const throw () {
-      return buf;
-    }
+    const char *what() const throw ();
   private:
     char buf[256];
   };