[master] 11a50e7 umem: test-load libumem in a separate namespace in the management process
Nils Goroll
nils.goroll at uplex.de
Wed Apr 4 14:49:11 UTC 2018
commit 11a50e7944fe3ae69e649204b9b6683b92d2e463
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 acb291a..7464a19 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