diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-10-09 16:02:55 +0200 |
---|---|---|
committer | Sven Eden <sven.eden@prydeworx.com> | 2018-10-29 10:18:31 +0100 |
commit | c38cb76e8aa42dcdbe5dacc0da55952a84afa7a6 (patch) | |
tree | 35bf6c86b53462c722e64104062ceec64eff3e73 /src/basic | |
parent | f02a0332640a57eefab440123b57ab1b3c8cd0d6 (diff) |
mempool: only enable mempool use when linked to libsystemd-shared.so
Mempool use is enabled or disabled based on the mempool_use_allowed symbol that
is linked in.
Should fix assert crashes in external programs caused by #9792.
Replaces #10286.
v2:
- use two different source files instead of a gcc constructor
(cherry picked from commit a5d8835c78112206bbf0812dd4cb471f803bfe88)
Diffstat (limited to 'src/basic')
-rw-r--r-- | src/basic/mempool.c | 2 | ||||
-rw-r--r-- | src/basic/mempool.h | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/src/basic/mempool.c b/src/basic/mempool.c index aaf46ceda..24a7d2b11 100644 --- a/src/basic/mempool.c +++ b/src/basic/mempool.c @@ -78,6 +78,8 @@ bool mempool_enabled(void) { if (!is_main_thread()) return false; + if (!mempool_use_allowed) + b = false; if (b < 0) b = getenv_bool("SYSTEMD_MEMPOOL") != 0; diff --git a/src/basic/mempool.h b/src/basic/mempool.h index e223fc16f..a9d6b4691 100644 --- a/src/basic/mempool.h +++ b/src/basic/mempool.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ #pragma once - +//#include <stdbool.h> #include <stddef.h> struct pool; @@ -23,6 +23,7 @@ static struct mempool pool_name = { \ .at_least = alloc_at_least, \ } +extern const bool mempool_use_allowed; bool mempool_enabled(void); #if VALGRIND |