mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-26 12:37:26 +00:00
remove usage of apr dso functions, we have our own dso abstraction
This commit is contained in:
parent
75c5c9807f
commit
5e0fc8f666
@ -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
|
* @defgroup switch_string String Handling funcions
|
||||||
* @ingroup switch_apr
|
* @ingroup switch_apr
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
|
|
||||||
static switch_memory_pool_t *memoryPool = NULL;
|
static switch_memory_pool_t *memoryPool = NULL;
|
||||||
static switch_dso_handle_t *javaVMHandle = NULL;
|
static switch_dso_lib_t javaVMHandle = NULL;
|
||||||
|
|
||||||
JavaVM *javaVM = NULL;
|
JavaVM *javaVM = NULL;
|
||||||
jclass launcherClass = NULL;
|
jclass launcherClass = NULL;
|
||||||
@ -188,6 +188,7 @@ static switch_status_t load_config(JavaVMOption **javaOptions, int *optionCount,
|
|||||||
{
|
{
|
||||||
switch_xml_t cfg, xml;
|
switch_xml_t cfg, xml;
|
||||||
switch_status_t status;
|
switch_status_t status;
|
||||||
|
char *derr = NULL;
|
||||||
|
|
||||||
xml = switch_xml_open_cfg("java.conf", &cfg, NULL);
|
xml = switch_xml_open_cfg("java.conf", &cfg, NULL);
|
||||||
if (xml)
|
if (xml)
|
||||||
@ -203,10 +204,11 @@ static switch_status_t load_config(JavaVMOption **javaOptions, int *optionCount,
|
|||||||
const char *path = switch_xml_attr_soft(javavm, "path");
|
const char *path = switch_xml_attr_soft(javavm, "path");
|
||||||
if (path != NULL)
|
if (path != NULL)
|
||||||
{
|
{
|
||||||
status = switch_dso_load(&javaVMHandle, path, memoryPool);
|
javaVMHandle = switch_dso_open(path, 0, &derr);
|
||||||
if (status != SWITCH_STATUS_SUCCESS)
|
if (derr || !dso) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error loading %s\n", path);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error loading %s\n", path);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Java VM path specified in java.conf.xml\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Java VM path specified in java.conf.xml\n");
|
||||||
@ -291,9 +293,11 @@ static switch_status_t create_java_vm(JavaVMOption *options, int optionCount, vm
|
|||||||
{
|
{
|
||||||
jint (JNICALL *pJNI_CreateJavaVM)(JavaVM**,void**,void*);
|
jint (JNICALL *pJNI_CreateJavaVM)(JavaVM**,void**,void*);
|
||||||
switch_status_t status;
|
switch_status_t status;
|
||||||
|
char *derr = NULL;
|
||||||
|
|
||||||
status = switch_dso_sym((void*) &pJNI_CreateJavaVM, javaVMHandle, "JNI_CreateJavaVM");
|
pJNI_CreateJavaVM = (void *)switch_dso_func_sym(javaVMHandle, "JNI_CreateJavaVM", &derr)
|
||||||
if (status == SWITCH_STATUS_SUCCESS)
|
|
||||||
|
if (!derr)
|
||||||
{
|
{
|
||||||
JNIEnv *env;
|
JNIEnv *env;
|
||||||
JavaVMInitArgs initArgs;
|
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);
|
switch_core_destroy_memory_pool(&memoryPool);
|
||||||
}
|
}
|
||||||
@ -398,7 +404,9 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_java_shutdown)
|
|||||||
exec_user_method(&vmControl.shutdown);
|
exec_user_method(&vmControl.shutdown);
|
||||||
(*javaVM)->DestroyJavaVM(javaVM);
|
(*javaVM)->DestroyJavaVM(javaVM);
|
||||||
javaVM = NULL;
|
javaVM = NULL;
|
||||||
switch_dso_unload(javaVMHandle);
|
if (javaVMHandle) {
|
||||||
|
switch_dso_destroy(&javaVMHandle);
|
||||||
|
}
|
||||||
switch_core_destroy_memory_pool(&memoryPool);
|
switch_core_destroy_memory_pool(&memoryPool);
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,6 @@
|
|||||||
#include <apr_thread_rwlock.h>
|
#include <apr_thread_rwlock.h>
|
||||||
#include <apr_file_io.h>
|
#include <apr_file_io.h>
|
||||||
#include <apr_poll.h>
|
#include <apr_poll.h>
|
||||||
#include <apr_dso.h>
|
|
||||||
#include <apr_strings.h>
|
#include <apr_strings.h>
|
||||||
#define APR_WANT_STDIO
|
#define APR_WANT_STDIO
|
||||||
#define APR_WANT_STRFUNC
|
#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);
|
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 */
|
/* 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)
|
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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user