]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
remove usage of apr dso functions, we have our own dso abstraction
authorMichael Jerris <mike@jerris.com>
Wed, 12 Mar 2014 23:02:43 +0000 (19:02 -0400)
committerMichael Jerris <mike@jerris.com>
Wed, 12 Mar 2014 23:02:49 +0000 (19:02 -0400)
src/include/switch_apr.h
src/mod/languages/mod_java/modjava.c
src/switch_apr.c

index fee9ed19243693b4ad59b682b0512a53a7763a32..1cfd279bfbb0ad644b329d0333d4f75fce21bcab 100644 (file)
@@ -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
index 428a9095be420be9002537dc9d3d5cac3831f985..79b0981052a2057dd7a1d06a6367bb347d13893e 100644 (file)
@@ -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;
 }
index 10b1291e892c0fec80f51a498cae6fb422951028..f3107303966d82e893e57c4ac782c5ac8fb90b10 100644 (file)
@@ -51,7 +51,6 @@
 #include <apr_thread_rwlock.h>
 #include <apr_file_io.h>
 #include <apr_poll.h>
-#include <apr_dso.h>
 #include <apr_strings.h>
 #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)