[6.0] 2adac3d59 umem: test-load libumem in a separate namespace in the management process
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Thu Aug 16 08:52:32 UTC 2018
commit 2adac3d59c4904027254656b3a6f13b4ab8aadf6
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Wed Apr 4 09:21:11 2018 +0200
umem: test-load libumem in a separate namespace in the management process
libumem's atfork handler will redefine malloc() and friends so if we
load it in the manager, we cannot confine its use to the stevedore
diff --git a/bin/varnishd/storage/storage_umem.c b/bin/varnishd/storage/storage_umem.c
index acb291a51..7464a199c 100644
--- a/bin/varnishd/storage/storage_umem.c
+++ b/bin/varnishd/storage/storage_umem.c
@@ -41,6 +41,7 @@
#include <stdlib.h>
#include <umem.h>
#include <dlfcn.h>
+#include <link.h>
#include "storage/storage.h"
#include "storage/storage_simple.h"
@@ -262,7 +263,8 @@ smu_init(struct stevedore *parent, int ac, char * const *av)
/* Check if these load in the management process. */
(void) dlerror();
- if ((libumem_hndl = dlopen("libumem.so", RTLD_NOW)) == NULL)
+ libumem_hndl = dlmopen(LM_ID_NEWLM, "libumem.so", RTLD_LAZY);
+ if (libumem_hndl == NULL)
ARGV_ERR("(-sumem) cannot open libumem.so: %s", dlerror());
#define DLSYM_UMEM(fptr,sym) \
@@ -282,6 +284,9 @@ smu_init(struct stevedore *parent, int ac, char * const *av)
#undef DLSYM_UMEM
+ AZ(dlclose(libumem_hndl));
+ libumem_hndl = NULL;
+
e = VNUM_2bytes(av[0], &u, 0);
if (e != NULL)
ARGV_ERR("(-sumem) size \"%s\": %s\n", av[0], e);
More information about the varnish-commit
mailing list