From: Sage Weil Date: Tue, 18 Oct 2016 16:03:28 +0000 (-0400) Subject: mempool: force per-type factories to register with the pool X-Git-Tag: v11.1.0~442^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=62fa72c0e168f73e7caaf4a772877fe505e87759;p=ceph.git mempool: force per-type factories to register with the pool 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 --- diff --git a/src/include/mempool.h b/src/include/mempool.h index b69c09d5435e..9988b5b3f4ab 100644 --- a/src/include/mempool.h +++ b/src/include/mempool.h @@ -272,19 +272,19 @@ public: typedef pool_allocator 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 pool_allocator(const pool_allocator&) { - 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 _factory_##pool##factoryname##_alloc = {}; + pool::pool_allocator \ + _factory_##pool##factoryname##_alloc = {true}; // Use this for each class that belongs to a mempool. For example, //