From 5e0fc8f66650fb8ceb136f0e1608effa0b38eba5 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Wed, 12 Mar 2014 19:02:43 -0400 Subject: [PATCH] remove usage of apr dso functions, we have our own dso abstraction --- src/include/switch_apr.h | 49 ---------------------------- src/mod/languages/mod_java/modjava.c | 22 +++++++++---- src/switch_apr.c | 23 ------------- 3 files changed, 15 insertions(+), 79 deletions(-) diff --git a/src/include/switch_apr.h b/src/include/switch_apr.h index fee9ed1924..1cfd279bfb 100644 --- a/src/include/switch_apr.h +++ b/src/include/switch_apr.h @@ -88,55 +88,6 @@ SWITCH_DECLARE(void) switch_pool_clear(switch_memory_pool_t *p); /** @} */ -/** - * @defgroup switch_dso Dynamic Object Handling Routines - * @ingroup switch_apr - * @{ - */ -/** - * Structure for referencing dynamic objects - */ - typedef struct apr_dso_handle_t switch_dso_handle_t; - -/** - * Structure for referencing symbols from dynamic objects - */ - typedef void *switch_dso_handle_sym_t; - -/** - * Load a DSO library. - * @param res_handle Location to store new handle for the DSO. - * @param path Path to the DSO library - * @param ctx Pool to use. - * @bug We aught to provide an alternative to RTLD_GLOBAL, which - * is the only supported method of loading DSOs today. - */ -SWITCH_DECLARE(switch_status_t) switch_dso_load(switch_dso_handle_t ** res_handle, const char *path, switch_memory_pool_t *ctx); - -/** - * Close a DSO library. - * @param handle handle to close. - */ -SWITCH_DECLARE(switch_status_t) switch_dso_unload(switch_dso_handle_t *handle); - -/** - * Load a symbol from a DSO handle. - * @param ressym Location to store the loaded symbol - * @param handle handle to load the symbol from. - * @param symname Name of the symbol to load. - */ -SWITCH_DECLARE(switch_status_t) switch_dso_sym(switch_dso_handle_sym_t *ressym, switch_dso_handle_t *handle, const char *symname); - -/** - * Report more information when a DSO function fails. - * @param dso The dso handle that has been opened - * @param buf Location to store the dso error - * @param bufsize The size of the provided buffer - */ -SWITCH_DECLARE(const char *) switch_dso_error(switch_dso_handle_t *dso, char *buf, size_t bufsize); - -/** @} */ - /** * @defgroup switch_string String Handling funcions * @ingroup switch_apr diff --git a/src/mod/languages/mod_java/modjava.c b/src/mod/languages/mod_java/modjava.c index 428a9095be..79b0981052 100644 --- a/src/mod/languages/mod_java/modjava.c +++ b/src/mod/languages/mod_java/modjava.c @@ -35,7 +35,7 @@ static switch_memory_pool_t *memoryPool = NULL; -static switch_dso_handle_t *javaVMHandle = NULL; +static switch_dso_lib_t javaVMHandle = NULL; JavaVM *javaVM = NULL; jclass launcherClass = NULL; @@ -188,6 +188,7 @@ static switch_status_t load_config(JavaVMOption **javaOptions, int *optionCount, { switch_xml_t cfg, xml; switch_status_t status; + char *derr = NULL; xml = switch_xml_open_cfg("java.conf", &cfg, NULL); if (xml) @@ -203,9 +204,10 @@ static switch_status_t load_config(JavaVMOption **javaOptions, int *optionCount, const char *path = switch_xml_attr_soft(javavm, "path"); if (path != NULL) { - status = switch_dso_load(&javaVMHandle, path, memoryPool); - if (status != SWITCH_STATUS_SUCCESS) + javaVMHandle = switch_dso_open(path, 0, &derr); + if (derr || !dso) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error loading %s\n", path); + } } else { @@ -291,9 +293,11 @@ static switch_status_t create_java_vm(JavaVMOption *options, int optionCount, vm { jint (JNICALL *pJNI_CreateJavaVM)(JavaVM**,void**,void*); switch_status_t status; + char *derr = NULL; - status = switch_dso_sym((void*) &pJNI_CreateJavaVM, javaVMHandle, "JNI_CreateJavaVM"); - if (status == SWITCH_STATUS_SUCCESS) + pJNI_CreateJavaVM = (void *)switch_dso_func_sym(javaVMHandle, "JNI_CreateJavaVM", &derr) + + if (!derr) { JNIEnv *env; JavaVMInitArgs initArgs; @@ -380,7 +384,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_java_load) } } - switch_dso_unload(javaVMHandle); + if (javaVMHandle) { + switch_dso_destroy(&javaVMHandle); + } } switch_core_destroy_memory_pool(&memoryPool); } @@ -398,7 +404,9 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_java_shutdown) exec_user_method(&vmControl.shutdown); (*javaVM)->DestroyJavaVM(javaVM); javaVM = NULL; - switch_dso_unload(javaVMHandle); + if (javaVMHandle) { + switch_dso_destroy(&javaVMHandle); + } switch_core_destroy_memory_pool(&memoryPool); return SWITCH_STATUS_SUCCESS; } diff --git a/src/switch_apr.c b/src/switch_apr.c index 10b1291e89..f310730396 100644 --- a/src/switch_apr.c +++ b/src/switch_apr.c @@ -51,7 +51,6 @@ #include #include #include -#include #include #define APR_WANT_STDIO #define APR_WANT_STRFUNC @@ -123,28 +122,6 @@ SWITCH_DECLARE(unsigned int) switch_hashfunc_default(const char *key, switch_ssi return apr_hashfunc_default(key, klen); } -/* DSO functions */ - -SWITCH_DECLARE(switch_status_t) switch_dso_load(switch_dso_handle_t ** res_handle, const char *path, switch_memory_pool_t *ctx) -{ - return apr_dso_load(res_handle, path, ctx); -} - -SWITCH_DECLARE(switch_status_t) switch_dso_unload(switch_dso_handle_t *handle) -{ - return apr_dso_unload(handle); -} - -SWITCH_DECLARE(switch_status_t) switch_dso_sym(switch_dso_handle_sym_t *ressym, switch_dso_handle_t *handle, const char *symname) -{ - return apr_dso_sym(ressym, handle, symname); -} - -SWITCH_DECLARE(const char *) switch_dso_error(switch_dso_handle_t *dso, char *buf, size_t bufsize) -{ - return apr_dso_error(dso, buf, bufsize); -} - /* string functions */ SWITCH_DECLARE(switch_status_t) switch_strftime(char *s, switch_size_t *retsize, switch_size_t max, const char *format, switch_time_exp_t *tm)