提交 14f4fbe9 编写于 作者: M Marek Habersack

[runtime] Use IOAMP-aware method of looking for domain configuration file

上级 f93bb42f
......@@ -816,7 +816,7 @@ void
mono_set_private_bin_path_from_config (MonoDomain *domain)
{
MonoError error;
gchar *config_file, *text;
gchar *config_file_name = NULL, *text = NULL, *config_file_path = NULL;
gsize len;
GMarkupParseContext *context;
RuntimeConfig runtime_config;
......@@ -825,21 +825,23 @@ mono_set_private_bin_path_from_config (MonoDomain *domain)
if (!domain || !domain->setup || !domain->setup->configuration_file)
return;
config_file = mono_string_to_utf8_checked (domain->setup->configuration_file, &error);
config_file_name = mono_string_to_utf8_checked (domain->setup->configuration_file, &error);
if (!mono_error_ok (&error)) {
mono_error_cleanup (&error);
return;
goto free_and_out;
}
if (!g_file_get_contents (config_file, &text, &len, NULL)) {
g_free (config_file);
return;
}
config_file_path = mono_portability_find_file (config_file_name, TRUE);
if (!config_file_path)
config_file_path = config_file_name;
if (!g_file_get_contents (config_file_path, &text, &len, NULL))
goto free_and_out;
runtime_config.runtime_count = 0;
runtime_config.assemblybinding_count = 0;
runtime_config.domain = domain;
runtime_config.filename = config_file;
runtime_config.filename = config_file_path;
offset = 0;
if (len > 3 && text [0] == '\xef' && text [1] == (gchar) '\xbb' && text [2] == '\xbf')
......@@ -849,8 +851,12 @@ mono_set_private_bin_path_from_config (MonoDomain *domain)
if (g_markup_parse_context_parse (context, text + offset, len - offset, NULL))
g_markup_parse_context_end_parse (context, NULL);
g_markup_parse_context_free (context);
free_and_out:
g_free (text);
g_free (config_file);
if (config_file_name != config_file_path)
g_free (config_file_name);
g_free (config_file_path);
}
MonoAppDomain *
......
......@@ -32,6 +32,7 @@
#include <mono/utils/mono-path.h>
#include <mono/metadata/reflection.h>
#include <mono/metadata/coree.h>
#include <mono/utils/mono-io-portability.h>
#ifndef HOST_WIN32
#include <sys/types.h>
......@@ -2457,11 +2458,17 @@ mono_assembly_apply_binding (MonoAssemblyName *aname, MonoAssemblyName *dest_nam
if (domain && domain->setup && domain->setup->configuration_file) {
mono_domain_lock (domain);
if (!domain->assembly_bindings_parsed) {
gchar *domain_config_file = mono_string_to_utf8 (domain->setup->configuration_file);
gchar *domain_config_file_name = mono_string_to_utf8 (domain->setup->configuration_file);
gchar *domain_config_file_path = mono_portability_find_file (domain_config_file_name, TRUE);
mono_config_parse_assembly_bindings (domain_config_file, aname->major, aname->minor, domain, assembly_binding_info_parsed);
if (!domain_config_file_path)
domain_config_file_path = domain_config_file_name;
mono_config_parse_assembly_bindings (domain_config_file_path, aname->major, aname->minor, domain, assembly_binding_info_parsed);
domain->assembly_bindings_parsed = TRUE;
g_free (domain_config_file);
if (domain_config_file_name != domain_config_file_path)
g_free (domain_config_file_name);
g_free (domain_config_file_path);
}
mono_domain_unlock (domain);
......
......@@ -77,6 +77,7 @@
#include <mono/utils/mono-string.h>
#include <mono/utils/mono-error-internals.h>
#include <mono/utils/mono-mmap.h>
#include <mono/utils/mono-io-portability.h>
#if defined (HOST_WIN32)
#include <windows.h>
......@@ -6920,7 +6921,7 @@ get_bundled_app_config (void)
const gchar *app_config;
MonoDomain *domain;
MonoString *file;
gchar *config_file;
gchar *config_file_name, *config_file_path;
gsize len;
gchar *module;
......@@ -6932,15 +6933,20 @@ get_bundled_app_config (void)
return NULL;
// Retrieve config file and remove the extension
config_file = mono_string_to_utf8 (file);
len = strlen (config_file) - strlen (".config");
config_file_name = mono_string_to_utf8 (file);
config_file_path = mono_portability_find_file (config_file_name, TRUE);
if (!config_file_path)
config_file_path = config_file_name;
len = strlen (config_file_path) - strlen (".config");
module = g_malloc0 (len + 1);
memcpy (module, config_file, len);
memcpy (module, config_file_path, len);
// Get the config file from the module name
app_config = mono_config_string_for_assembly_file (module);
// Clean-up
g_free (module);
g_free (config_file);
if (config_file_name != config_file_path)
g_free (config_file_name);
g_free (config_file_path);
if (!app_config)
return NULL;
......
......@@ -25,7 +25,6 @@ mono_portability_helpers_init (void)
gchar *
mono_portability_find_file (const gchar *pathname, gboolean last_exists)
{
g_assert_not_reached();
return NULL;
}
......@@ -147,7 +146,11 @@ static inline void do_mono_profiler_iomap (GString **report, const char *pathnam
gchar *mono_portability_find_file (const gchar *pathname, gboolean last_exists)
{
GString *report = NULL;
gchar *ret = mono_portability_find_file_internal (&report, pathname, last_exists);
gchar *ret;
if (!pathname || !pathname [0])
return NULL;
ret = mono_portability_find_file_internal (&report, pathname, last_exists);
if (report)
g_string_free (report, TRUE);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册