]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mempool: simplify initialization
authorSage Weil <sage@redhat.com>
Tue, 18 Oct 2016 16:01:52 +0000 (12:01 -0400)
committerSage Weil <sage@redhat.com>
Wed, 2 Nov 2016 17:48:49 +0000 (13:48 -0400)
Assume that the array will be zeroed when the process starts, and
avoid the possibility that it will be zeroed *again* when the
ctors run for this link module (potentially clobbering values
that have been filled in by other ctors who ran earlier than
ours).

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

index 209cee0d3e7e67af44ae0bebe5d2f14baed794b9..413353d4a0fc12170ece913aed12f15b1d5c2667 100644 (file)
@@ -21,11 +21,11 @@ static bool debug_mode = false;
 
 // --------------------------------------------------------------
 
-static mempool::pool_t *pools[mempool::num_pools] = {
-#define P(x) nullptr,
-   DEFINE_MEMORY_POOLS_HELPER(P)
-#undef P
-};
+// We rely on this array of pointers being zeroed when the process
+// starts *before* the ctors from *any* linked modules are executed.
+// That way, regardless of link order, pool_t's are allocated and
+// instantiated on demand.
+static mempool::pool_t *pools[mempool::num_pools];
 
 mempool::pool_t& mempool::get_pool(mempool::pool_index_t ix)
 {