summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
25a5bed)
This could result in a unecessary wait on shutdown where the selector thread would have exited, and the finalizer thread would try to dispose a Socket, which would try to remove the socket from the IOSelector. This removal operation would wait on the selector thread to acknowledge the removal, but because the selector thread would have alreday exited, we would wait on an event that would never happen.
MonoError error;
MonoGHashTable *states;
MonoError error;
MonoGHashTable *states;
- io_selector_running = TRUE;
-
if (mono_runtime_is_shutting_down ()) {
io_selector_running = FALSE;
return 0;
if (mono_runtime_is_shutting_down ()) {
io_selector_running = FALSE;
return 0;
mono_g_hash_table_destroy (states);
mono_g_hash_table_destroy (states);
+ mono_coop_mutex_lock (&threadpool_io->updates_lock);
+
io_selector_running = FALSE;
io_selector_running = FALSE;
+ mono_coop_cond_broadcast (&threadpool_io->updates_cond);
+
+ mono_coop_mutex_unlock (&threadpool_io->updates_lock);
if (!threadpool_io->backend.init (threadpool_io->wakeup_pipes [0]))
g_error ("initialize: backend->init () failed");
if (!threadpool_io->backend.init (threadpool_io->wakeup_pipes [0]))
g_error ("initialize: backend->init () failed");
+ mono_coop_mutex_lock (&threadpool_io->updates_lock);
+
+ io_selector_running = TRUE;
+
MonoError error;
if (!mono_thread_create_internal (mono_get_root_domain (), selector_thread, NULL, MONO_THREAD_CREATE_FLAGS_THREADPOOL | MONO_THREAD_CREATE_FLAGS_SMALL_STACK, &error))
g_error ("initialize: mono_thread_create_internal () failed due to %s", mono_error_get_message (&error));
MonoError error;
if (!mono_thread_create_internal (mono_get_root_domain (), selector_thread, NULL, MONO_THREAD_CREATE_FLAGS_THREADPOOL | MONO_THREAD_CREATE_FLAGS_SMALL_STACK, &error))
g_error ("initialize: mono_thread_create_internal () failed due to %s", mono_error_get_message (&error));
+
+ mono_coop_mutex_unlock (&threadpool_io->updates_lock);
mono_coop_mutex_lock (&threadpool_io->updates_lock);
mono_coop_mutex_lock (&threadpool_io->updates_lock);
+ if (!io_selector_running) {
+ mono_coop_mutex_unlock (&threadpool_io->updates_lock);
+ return;
+ }
+
update = update_get_new ();
update->type = UPDATE_ADD;
update->data.add.fd = GPOINTER_TO_INT (handle);
update = update_get_new ();
update->type = UPDATE_ADD;
update->data.add.fd = GPOINTER_TO_INT (handle);
mono_coop_mutex_lock (&threadpool_io->updates_lock);
mono_coop_mutex_lock (&threadpool_io->updates_lock);
+ if (!io_selector_running) {
+ mono_coop_mutex_unlock (&threadpool_io->updates_lock);
+ return;
+ }
+
update = update_get_new ();
update->type = UPDATE_REMOVE_SOCKET;
update->data.add.fd = fd;
update = update_get_new ();
update->type = UPDATE_REMOVE_SOCKET;
update->data.add.fd = fd;
mono_coop_mutex_lock (&threadpool_io->updates_lock);
mono_coop_mutex_lock (&threadpool_io->updates_lock);
+ if (!io_selector_running) {
+ mono_coop_mutex_unlock (&threadpool_io->updates_lock);
+ return;
+ }
+
update = update_get_new ();
update->type = UPDATE_REMOVE_DOMAIN;
update->data.remove_domain.domain = domain;
update = update_get_new ();
update->type = UPDATE_REMOVE_DOMAIN;
update->data.remove_domain.domain = domain;