* 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;
}