]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: throw std::bad_alloc on boost:pool<> depletion
authorSage Weil <sage@newdream.net>
Thu, 15 Jul 2010 18:38:08 +0000 (11:38 -0700)
committerSage Weil <sage@newdream.net>
Thu, 15 Jul 2010 21:51:29 +0000 (14:51 -0700)
A bit more informative than a segfault from this=NULL in the constructor.

Signed-off-by: Sage Weil <sage@newdream.net>
src/mds/CDentry.h
src/mds/CDir.h
src/mds/CInode.h
src/mds/Capability.h

index 0971156b060ee4a3d9588f3f725e4ca144909e14..b67a71549a9579af0b91dfcfc8f0d13c89ea93c0 100644 (file)
@@ -53,7 +53,10 @@ private:
   static boost::pool<> pool;
 public:
   static void *operator new(size_t num_bytes) { 
-    return pool.malloc();
+    void *n = pool.malloc();
+    if (!n)
+      throw std::bad_alloc();
+    return n;
   }
   void operator delete(void *p) {
     pool.free(p);
index 18ee0785eacbdf1eb0be42102ef141f7d329ba17..a01e57311e62c7ff79e1f2447e578d737d2c36f5 100644 (file)
@@ -49,7 +49,10 @@ private:
   static boost::pool<> pool;
 public:
   static void *operator new(size_t num_bytes) { 
-    return pool.malloc();
+    void *n = pool.malloc();
+    if (!n)
+      throw std::bad_alloc();
+    return n;
   }
   void operator delete(void *p) {
     pool.free(p);
index 2d6d0e903ef15df9f86eee4f5796025e0fb9addd..e1aec5ee30b32e833671f833397b7a662c7cff29 100644 (file)
@@ -61,7 +61,10 @@ private:
   static boost::pool<> pool;
 public:
   static void *operator new(size_t num_bytes) { 
-    return pool.malloc();
+    void *n = pool.malloc();
+    if (!n)
+      throw std::bad_alloc();
+    return n;
   }
   void operator delete(void *p) {
     pool.free(p);
index 8bc5c90faa3f8faa2a6138b0aa3b05c08ea4ea05..4793289834069f946698a69d650ecdb680deed9b 100644 (file)
@@ -62,7 +62,10 @@ private:
   static boost::pool<> pool;
 public:
   static void *operator new(size_t num_bytes) { 
-    return pool.malloc();
+    void *n = pool.malloc();
+    if (!n)
+      throw std::bad_alloc();
+    return n;
   }
   void operator delete(void *p) {
     pool.free(p);