From 49631175231ff1f06ec2c097575c14b0a347478e Mon Sep 17 00:00:00 2001 From: Michael Giagnocavo Date: Tue, 20 Jan 2009 22:35:15 +0000 Subject: [PATCH] This should fix mono crash on Linux git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11324 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/languages/mod_managed/freeswitch_managed.h | 1 + src/mod/languages/mod_managed/mod_managed.cpp | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mod/languages/mod_managed/freeswitch_managed.h b/src/mod/languages/mod_managed/freeswitch_managed.h index 6bc6f6d617..e21d404bca 100644 --- a/src/mod/languages/mod_managed/freeswitch_managed.h +++ b/src/mod/languages/mod_managed/freeswitch_managed.h @@ -47,6 +47,7 @@ typedef char* (*inputFunction)(void*, switch_input_type_t); #include #include #include +#include #include #include #endif diff --git a/src/mod/languages/mod_managed/mod_managed.cpp b/src/mod/languages/mod_managed/mod_managed.cpp index b2ad33c016..c14c521d07 100644 --- a/src/mod/languages/mod_managed/mod_managed.cpp +++ b/src/mod/languages/mod_managed/mod_managed.cpp @@ -49,7 +49,7 @@ using namespace System::Runtime::InteropServices; SWITCH_BEGIN_EXTERN_C SWITCH_MODULE_LOAD_FUNCTION(mod_managed_load); -SWITCH_MODULE_DEFINITION(mod_managed, mod_managed_load, NULL, NULL); +SWITCH_MODULE_DEFINITION_EX(mod_managed, mod_managed_load, NULL, NULL, SMODF_GLOBAL_SYMBOLS); SWITCH_STANDARD_API(managedrun_api_function); /* ExecuteBackground */ SWITCH_STANDARD_API(managed_api_function); /* Execute */ @@ -186,6 +186,11 @@ switch_status_t loadRuntime() return SWITCH_STATUS_FALSE; } +#ifndef WIN32 + // So linux can find the .so + mono_config_parse_memory(""); +#endif + switch_snprintf(filename, 256, "%s%s%s", SWITCH_GLOBAL_dirs.mod_dir, SWITCH_PATH_SEPARATOR, MOD_MANAGED_DLL); globals.domain = mono_jit_init(filename); @@ -336,13 +341,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_managed_load) /* Run loader */ MonoObject * exception = NULL; MonoObject * objResult = mono_runtime_invoke(globals.loadMethod, NULL, NULL, &exception); - success = *(int *) mono_object_unbox(objResult); - if (exception) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Load threw an exception.\n"); mono_print_unhandled_exception(exception); return SWITCH_STATUS_FALSE; } + success = *(int *) mono_object_unbox(objResult); #endif if (success) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Load completed successfully.\n");