X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Fattach.c;h=2c4372ba4b493fed8b441d6704c31c88a713da4c;hb=7bd7446abcbe2c93be78fd97221dcddaeb92d653;hp=9e54462633cf92da422cb9e8d06a9783b4dae022;hpb=69f207ee9e4f440e66e98bf5f685807f6527c39d;p=mono.git diff --git a/mono/metadata/attach.c b/mono/metadata/attach.c index 9e54462633c..2c4372ba4b4 100644 --- a/mono/metadata/attach.c +++ b/mono/metadata/attach.c @@ -94,7 +94,7 @@ static char *ipc_filename; static char *server_uri; -static HANDLE receiver_thread_handle; +static MonoThreadHandle *receiver_thread_handle; static gboolean stop_receiver_thread; @@ -102,7 +102,7 @@ static gboolean needs_to_start, started; static void transport_connect (void); -static guint32 WINAPI receiver_thread (void *arg); +static gsize WINAPI receiver_thread (void *arg); static void transport_start_receive (void); @@ -260,7 +260,7 @@ mono_attach_cleanup (void) /* Wait for the receiver thread to exit */ if (receiver_thread_handle) - WaitForSingleObjectEx (receiver_thread_handle, 0, FALSE); + mono_thread_info_wait_one_handle (receiver_thread_handle, 0, FALSE); } static int @@ -302,18 +302,30 @@ mono_attach_load_agent (MonoDomain *domain, char *agent, char *args, MonoObject return 1; } + + main_args = (MonoArray*)mono_array_new_checked (domain, mono_defaults.string_class, (args == NULL) ? 0 : 1, &error); + if (main_args == NULL) { + g_print ("Could not allocate main method args due to %s\n", mono_error_get_message (&error)); + mono_error_cleanup (&error); + g_free (agent); + return 1; + } + if (args) { - main_args = (MonoArray*)mono_array_new (domain, mono_defaults.string_class, 1); mono_array_set (main_args, MonoString*, 0, mono_string_new (domain, args)); - } else { - main_args = (MonoArray*)mono_array_new (domain, mono_defaults.string_class, 0); } - g_free (agent); pa [0] = main_args; mono_runtime_try_invoke (method, NULL, pa, exc, &error); - mono_error_raise_exception (&error); /* FIXME don't raise here */ + if (!is_ok (&error)) { + g_print ("The entry point method of assembly '%s' could not be executed due to %s\n", agent, mono_error_get_message (&error)); + mono_error_cleanup (&error); + g_free (agent); + return 1; + } + + g_free (agent); return 0; } @@ -468,18 +480,21 @@ transport_start_receive (void) if (!listen_fd) return; - receiver_thread_handle = mono_threads_create_thread (receiver_thread, NULL, 0, 0, NULL); + receiver_thread_handle = mono_threads_create_thread (receiver_thread, NULL, NULL, NULL); g_assert (receiver_thread_handle); } -static guint32 WINAPI +static gsize WINAPI receiver_thread (void *arg) { + MonoError error; int res, content_len; guint8 buffer [256]; guint8 *p, *p_end; MonoObject *exc; + mono_native_thread_set_name (mono_native_thread_id_get (), "Attach receiver"); + printf ("attach: Listening on '%s'...\n", server_uri); while (TRUE) { @@ -490,11 +505,13 @@ receiver_thread (void *arg) printf ("attach: Connected.\n"); - mono_thread_attach (mono_get_root_domain ()); + MonoThread *thread = mono_thread_attach (mono_get_root_domain ()); + mono_thread_set_name_internal (thread->internal_thread, mono_string_new (mono_get_root_domain (), "Attach receiver"), TRUE, &error); + mono_error_assert_ok (&error); /* Ask the runtime to not abort this thread */ //mono_thread_current ()->flags |= MONO_THREAD_FLAG_DONT_MANAGE; /* Ask the runtime to not wait for this thread */ - mono_thread_internal_current ()->state |= ThreadState_Background; + thread->internal_thread->state |= ThreadState_Background; while (TRUE) { char *cmd, *agent_name, *agent_args;