]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mempool: force per-type factories to register with the pool
authorSage Weil <sage@redhat.com>
Tue, 18 Oct 2016 16:03:28 +0000 (12:03 -0400)
committerSage Weil <sage@redhat.com>
Wed, 2 Nov 2016 17:48:49 +0000 (13:48 -0400)
We want these to get their debug flag adjusted when it is turned
on and off.

(In contrast, we accept that STL containers will only be debugged
if mempool debug was on when they are constructed.)

Signed-off-by: Sage Weil <sage@redhat.com>
src/include/mempool.h

index b69c09d5435e19b08f1e11d0e7a7e573c9de80a2..9988b5b3f4ab23287be308c5e8555350cc96eb83 100644 (file)
@@ -272,19 +272,19 @@ public:
     typedef pool_allocator<pool_ix,U> other;
   };
 
-  void init() {
+  void init(bool force_register) {
     pool = &get_pool(pool_ix);
-    if (pool) {
+    if (pool->debug || force_register) {
       type = pool->get_type(typeid(T), sizeof(T));
     }
   }
 
-  pool_allocator() {
-    init();
+  pool_allocator(bool force_register=false) {
+    init(force_register);
   }
   template<typename U>
   pool_allocator(const pool_allocator<pool_ix,U>&) {
-    init();
+    init(false);
   }
 
   T* allocate(size_t n, void *p = nullptr) {
@@ -393,7 +393,8 @@ DEFINE_MEMORY_POOLS_HELPER(P)
 // Use this for any type that is contained by a container (unless it
 // is a class you defined; see below).
 #define MEMPOOL_DEFINE_FACTORY(obj, factoryname, pool)                 \
-  pool::pool_allocator<obj> _factory_##pool##factoryname##_alloc = {};
+  pool::pool_allocator<obj>                                            \
+  _factory_##pool##factoryname##_alloc = {true};
 
 // Use this for each class that belongs to a mempool.  For example,
 //