1
0
mirror of https://github.com/systemd/systemd synced 2025-10-06 00:13:24 +02:00
Files
systemd/src/shared/enable-mempool.c
Zbigniew Jędrzejewski-Szmek b01f31954f Turn mempool_enabled() into a weak symbol
Before we had the following scheme:
mempool_enabled() would check mempool_use_allowed, and
libsystemd-shared would be linked with a .c file that provides mempool_use_allowed=true,
while other things would linked with a different .c file with mempool_use_allowed=false.

In the new scheme, mempool_enabled() itself is a weak symbol. If it's
not found, we assume false. So it only needs to be provided for libsystemd-shared,
where it can return false or true.

test-set-disable-mempool is libshared, so it gets the symbol. But then we
actually disable the mempool via envvar. mempool_enable() is called to check
its return value directly.
2022-06-29 16:51:52 +02:00

20 lines
374 B
C

/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <stdbool.h>
#include "env-util.h"
#include "mempool.h"
#include "process-util.h"
bool mempool_enabled(void) {
static int cache = -1;
if (!is_main_thread())
return false;
if (cache < 0)
cache = getenv_bool("SYSTEMD_MEMPOOL") != 0;
return cache;
}