]> git.proxmox.com Git - systemd.git/blobdiff - src/basic/mempool.c
New upstream version 240
[systemd.git] / src / basic / mempool.c
index a5ec8a1020362c8dea7af0265f2bac17057740f7..159c963377888dc822c5e2faf4d395c0f53fa7f3 100644 (file)
@@ -3,8 +3,10 @@
 #include <stdint.h>
 #include <stdlib.h>
 
+#include "env-util.h"
 #include "macro.h"
 #include "mempool.h"
+#include "process-util.h"
 #include "util.h"
 
 struct pool {
@@ -70,8 +72,21 @@ void mempool_free_tile(struct mempool *mp, void *p) {
         mp->freelist = p;
 }
 
-#if VALGRIND
+bool mempool_enabled(void) {
+        static int b = -1;
+
+        if (!is_main_thread())
+                return false;
 
+        if (!mempool_use_allowed)
+                b = false;
+        if (b < 0)
+                b = getenv_bool("SYSTEMD_MEMPOOL") != 0;
+
+        return b;
+}
+
+#if VALGRIND
 void mempool_drop(struct mempool *mp) {
         struct pool *p = mp->first_pool;
         while (p) {
@@ -81,5 +96,4 @@ void mempool_drop(struct mempool *mp) {
                 p = n;
         }
 }
-
 #endif