/** @} */
-/**
- * @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
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;
{
switch_xml_t cfg, xml;
switch_status_t status;
+ char *derr = NULL;
xml = switch_xml_open_cfg("java.conf", &cfg, NULL);
if (xml)
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
{
{
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;
}
}
- switch_dso_unload(javaVMHandle);
+ if (javaVMHandle) {
+ switch_dso_destroy(&javaVMHandle);
+ }
}
switch_core_destroy_memory_pool(&memoryPool);
}
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;
}
#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
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)