* [threadpool] Increase and decrease refcount when removing domain
* [threadpool] Fix unload-appdomain-on-shutdown.exe
If the threadpool is not initialized, there is no need to initialize it, as no worker is going to start in the domain because mono_domain_is_unloading would return TRUE.
* The is_unloading () check in worker_request () ensures that
* no new jobs are added after we enter the lock below.
*/
- mono_lazy_initialize (&status, initialize);
+
+ if (!mono_lazy_is_initialized (&status))
+ return TRUE;
+
+ mono_refcount_inc (threadpool);
+
domains_lock ();
tpdomain = tpdomain_get (domain, FALSE);
if (!tpdomain) {
domains_unlock ();
+ mono_refcount_dec (threadpool);
return TRUE;
}
mono_coop_cond_destroy (&tpdomain->cleanup_cond);
tpdomain_free (tpdomain);
+ mono_refcount_dec (threadpool);
+
return ret;
}