From: Sage Weil Date: Tue, 18 Oct 2016 16:01:52 +0000 (-0400) Subject: mempool: simplify initialization X-Git-Tag: v11.1.0~442^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bfeaed64120d4bb443bc6dfed4b2450533f3048e;p=ceph.git mempool: simplify initialization 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 --- diff --git a/src/global/mempool.cc b/src/global/mempool.cc index 209cee0d3e7e..413353d4a0fc 100644 --- a/src/global/mempool.cc +++ b/src/global/mempool.cc @@ -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) {