From: Florian Forster Date: Tue, 30 Nov 2010 07:46:45 +0000 (+0100) Subject: dotnet plugin: "Attaching" the thread seems to resolve the segfaults. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=239f9f14888412400c03f2461b89a46888e0d027;p=collectd.git dotnet plugin: "Attaching" the thread seems to resolve the segfaults. --- diff --git a/src/dotnet.c b/src/dotnet.c index 3ba4f102..8d01258a 100644 --- a/src/dotnet.c +++ b/src/dotnet.c @@ -32,6 +32,7 @@ #include #include #include +#include struct dotnet_callback_info_s { @@ -49,6 +50,9 @@ static int dotnet_read (user_data_t *ud) /* {{{ */ MonoObject *object; MonoMethod *method; MonoObject *ret; + MonoThread *thread; + + thread = mono_thread_attach (domain); #if 0 MonoDomain *domain; @@ -68,6 +72,7 @@ static int dotnet_read (user_data_t *ud) /* {{{ */ if (object == NULL) { ERROR ("dotnet plugin: mono_gchandle_get_target failed."); + mono_thread_detach (thread); return (-1); } @@ -76,6 +81,7 @@ static int dotnet_read (user_data_t *ud) /* {{{ */ if (class == NULL) { ERROR ("dotnet plugin: mono_object_get_class failed."); + mono_thread_detach (thread); return (-1); } @@ -85,6 +91,7 @@ static int dotnet_read (user_data_t *ud) /* {{{ */ if (method == NULL) { ERROR ("dotnet plugin: mono_class_get_method_from_name failed."); + mono_thread_detach (thread); return (-1); } @@ -93,6 +100,7 @@ static int dotnet_read (user_data_t *ud) /* {{{ */ /* exception ptr = */ NULL); DEBUG ("dotnet plugin: mono_runtime_invoke returned %p.", (void *) ret); + mono_thread_detach (thread); return (0); } /* }}} int dotnet_read */