[Freeswitch-svn] [commit] r10306 - in freeswitch/trunk/src: . include mod/asr_tts/mod_cepstral mod/languages/mod_lua
FreeSWITCH SVN
mikej at freeswitch.org
Sat Nov 8 03:21:54 PST 2008
Author: mikej
Date: Sat Nov 8 06:21:54 2008
New Revision: 10306
Log:
(LBAPR-1) load mod_lua with global symbols space so that sub modules are able to link to it properly. Broken in svn r9605.
Modified:
freeswitch/trunk/src/include/switch_types.h
freeswitch/trunk/src/mod/asr_tts/mod_cepstral/mod_cepstral.c
freeswitch/trunk/src/mod/languages/mod_lua/mod_lua.cpp
freeswitch/trunk/src/switch_loadable_module.c
Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h (original)
+++ freeswitch/trunk/src/include/switch_types.h Sat Nov 8 06:21:54 2008
@@ -1355,7 +1355,7 @@
typedef struct switch_network_list switch_network_list_t;
-#define SWITCH_API_VERSION 1
+#define SWITCH_API_VERSION 2
#define SWITCH_MODULE_LOAD_ARGS (switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool)
#define SWITCH_MODULE_RUNTIME_ARGS (void)
#define SWITCH_MODULE_SHUTDOWN_ARGS (void)
@@ -1366,22 +1366,32 @@
#define SWITCH_MODULE_RUNTIME_FUNCTION(name) switch_status_t name SWITCH_MODULE_RUNTIME_ARGS
#define SWITCH_MODULE_SHUTDOWN_FUNCTION(name) switch_status_t name SWITCH_MODULE_SHUTDOWN_ARGS
+typedef enum {
+ SMODF_NONE = 0,
+ SMODF_GLOBAL_SYMBOLS = (1 << 0)
+} switch_module_flag_enum_t;
+typedef uint32_t switch_module_flag_t;
+
typedef struct switch_loadable_module_function_table {
int switch_api_version;
switch_module_load_t load;
switch_module_shutdown_t shutdown;
switch_module_runtime_t runtime;
+ switch_module_flag_t flags;
} switch_loadable_module_function_table_t;
-#define SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime) \
+#define SWITCH_MODULE_DEFINITION_EX(name, load, shutdown, runtime, flags) \
static const char modname[] = #name ; \
SWITCH_MOD_DECLARE_DATA switch_loadable_module_function_table_t name##_module_interface = { \
SWITCH_API_VERSION, \
load, \
shutdown, \
- runtime \
+ runtime, \
+ flags \
}
+#define SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime) \
+ SWITCH_MODULE_DEFINITION_EX(name, load, shutdown, runtime, SMODF_NONE)
/* things we don't deserve to know about */
/*! \brief A channel */
Modified: freeswitch/trunk/src/mod/asr_tts/mod_cepstral/mod_cepstral.c
==============================================================================
--- freeswitch/trunk/src/mod/asr_tts/mod_cepstral/mod_cepstral.c (original)
+++ freeswitch/trunk/src/mod/asr_tts/mod_cepstral/mod_cepstral.c Sat Nov 8 06:21:54 2008
@@ -52,7 +52,7 @@
#define SWIFT_FAILED(r) ((void *)(r) < (void *)0)
SWITCH_MODULE_LOAD_FUNCTION(mod_cepstral_load);
-SWITCH_MODULE_DEFINITION(mod_cepstral, mod_cepstral_load, NULL, NULL);
+SWITCH_MODULE_DEFINITION_EX(mod_cepstral, mod_cepstral_load, NULL, NULL, SMODF_GLOBAL_SYMBOLS);
static swift_engine *engine;
Modified: freeswitch/trunk/src/mod/languages/mod_lua/mod_lua.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/mod_lua.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/mod_lua.cpp Sat Nov 8 06:21:54 2008
@@ -40,8 +40,7 @@
SWITCH_MODULE_LOAD_FUNCTION(mod_lua_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_lua_shutdown);
-SWITCH_MODULE_DEFINITION(mod_lua, mod_lua_load, mod_lua_shutdown, NULL);
-
+SWITCH_MODULE_DEFINITION_EX(mod_lua, mod_lua_load, mod_lua_shutdown, NULL, SMODF_GLOBAL_SYMBOLS);
static struct {
switch_memory_pool_t *pool;
char *xml_handler;
Modified: freeswitch/trunk/src/switch_loadable_module.c
==============================================================================
--- freeswitch/trunk/src/switch_loadable_module.c (original)
+++ freeswitch/trunk/src/switch_loadable_module.c Sat Nov 8 06:21:54 2008
@@ -691,6 +691,7 @@
char *derr = NULL;
const char *err = NULL;
switch_memory_pool_t *pool;
+ switch_bool_t load_global = global;
switch_assert(path != NULL);
@@ -700,11 +701,11 @@
struct_name = switch_core_sprintf(pool, "%s_module_interface", filename);
#ifdef WIN32
- dso = switch_dso_open("FreeSwitch.dll", global, &derr);
+ dso = switch_dso_open("FreeSwitch.dll", load_global, &derr);
#elif defined (MACOSX) || defined(DARWIN)
- dso = switch_dso_open(SWITCH_PREFIX_DIR "/lib/libfreeswitch.dylib", global, &derr);
+ dso = switch_dso_open(SWITCH_PREFIX_DIR "/lib/libfreeswitch.dylib", load_global, &derr);
#else
- dso = switch_dso_open(NULL, global, &derr);
+ dso = switch_dso_open(NULL, load_global, &derr);
#endif
if (!derr && dso) {
interface_struct_handle = switch_dso_data_sym(dso, struct_name, &derr);
@@ -713,7 +714,7 @@
switch_safe_free(derr)
if (!interface_struct_handle) {
- dso = switch_dso_open(path, global, &derr);
+ dso = switch_dso_open(path, load_global, &derr);
}
while (loading) {
@@ -731,6 +732,20 @@
break;
}
+ if (interface_struct_handle && interface_struct_handle->switch_api_version != SWITCH_API_VERSION) {
+ err = "Trying to load an out of date module, please rebuild the module.";
+ break;
+ }
+
+ if (!load_global && interface_struct_handle && switch_test_flag(interface_struct_handle, SMODF_GLOBAL_SYMBOLS)) {
+ load_global = SWITCH_TRUE;
+ switch_dso_destroy(&dso);
+ interface_struct_handle = NULL;
+ dso = switch_dso_open(path, load_global, &derr);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Loading module with global namespace at request of module\n");
+ continue;
+ }
+
if (interface_struct_handle) {
mod_interface_functions = interface_struct_handle;
load_func_ptr = mod_interface_functions->load;
More information about the Freeswitch-svn
mailing list