[Freeswitch-svn] [commit] r11324 - freeswitch/trunk/src/mod/languages/mod_managed

FreeSWITCH SVN michaelgg at freeswitch.org
Tue Jan 20 14:35:15 PST 2009


Author: michaelgg
Date: Tue Jan 20 16:35:15 2009
New Revision: 11324

Log:
This should fix mono crash on Linux

Modified:
   freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_managed.h
   freeswitch/trunk/src/mod/languages/mod_managed/mod_managed.cpp

Modified: freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_managed.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_managed.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_managed.h	Tue Jan 20 16:35:15 2009
@@ -47,6 +47,7 @@
 #include <mono/jit/jit.h>
 #include <mono/metadata/assembly.h>
 #include <mono/metadata/environment.h>
+#include <mono/metadata/mono-config.h>
 #include <mono/metadata/threads.h>
 #include <mono/metadata/debug-helpers.h>
 #endif

Modified: freeswitch/trunk/src/mod/languages/mod_managed/mod_managed.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_managed/mod_managed.cpp	(original)
+++ freeswitch/trunk/src/mod/languages/mod_managed/mod_managed.cpp	Tue Jan 20 16:35:15 2009
@@ -49,7 +49,7 @@
 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 @@
 		return SWITCH_STATUS_FALSE;
 	}
 
+#ifndef WIN32 	
+	// So linux can find the .so
+	mono_config_parse_memory("<configuration><dllmap dll=\"mod_managed\" target=\"mod_managed.so\"/></configuration>");
+#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 @@
 	/* 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");



More information about the Freeswitch-svn mailing list