Skip to content

Commit 96333d2

Browse files
committed
do not destroy proxy lib pool before umf lib
1 parent 13bd6dd commit 96333d2

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/utils/utils_common.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include <umf/base.h>
1919
#include <umf/memory_provider.h>
2020

21+
#include "utils_load_library.h"
22+
2123
#ifdef __cplusplus
2224
extern "C" {
2325
#endif
@@ -79,6 +81,15 @@ static inline int utils_env_var_has_str(const char *envvar, const char *str) {
7981

8082
// check if we are running in the proxy library
8183
static inline int utils_is_running_in_proxy_lib(void) {
84+
// check if the proxy library is loaded using dlopen()
85+
void *proxy_lib_handle =
86+
utils_open_library("libumf_proxy.so", UMF_UTIL_OPEN_LIBRARY_NO_LOAD);
87+
if (proxy_lib_handle) {
88+
utils_close_library(proxy_lib_handle);
89+
return 1;
90+
}
91+
92+
// check if the proxy library is loaded using LD_PRELOAD
8293
return utils_env_var_get_str("LD_PRELOAD", "libumf_proxy.so") ? 1 : 0;
8394
}
8495

src/utils/utils_load_library.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,16 @@ void *utils_open_library(const char *filename, int userFlags) {
7979
LOG_FATAL("dlopen(%s) failed with error: %s", filename, dlerror());
8080
}
8181

82+
LOG_DEBUG("Opened library %s with handle %p", filename, handle);
83+
8284
return handle;
8385
}
8486

85-
int utils_close_library(void *handle) { return dlclose(handle); }
87+
int utils_close_library(void *handle) {
88+
LOG_DEBUG("Closing library handle %p", handle);
89+
90+
return dlclose(handle);
91+
}
8692

8793
void *utils_get_symbol_addr(void *handle, const char *symbol,
8894
const char *libname) {

0 commit comments

Comments
 (0)