#endif
if(destroy==TRUE) {
+ WapiHandleType type = _wapi_private_handles[idx].type;
+
#ifdef DEBUG
g_message ("%s: Destroying handle %p", __func__, handle);
#endif
_wapi_private_handles[idx].type = WAPI_HANDLE_UNUSED;
- /* Destroy the mutex and cond var. We hope nobody
- * tried to grab them between the handle unlock and
- * now, but pthreads doesn't have a
- * "unlock_and_destroy" atomic function.
- */
- thr_ret = mono_mutex_destroy (&_wapi_private_handles[idx].signal_mutex);
- g_assert (thr_ret == 0);
-
- thr_ret = pthread_cond_destroy (&_wapi_private_handles[idx].signal_cond);
- g_assert (thr_ret == 0);
+ if (!_WAPI_SHARED_HANDLE(type)) {
+ /* Destroy the mutex and cond var. We hope nobody
+ * tried to grab them between the handle unlock and
+ * now, but pthreads doesn't have a
+ * "unlock_and_destroy" atomic function.
+ */
+ thr_ret = mono_mutex_destroy (&_wapi_private_handles[idx].signal_mutex);
+ g_assert (thr_ret == 0);
+
+ thr_ret = pthread_cond_destroy (&_wapi_private_handles[idx].signal_cond);
+ g_assert (thr_ret == 0);
+ }
/* The garbage collector will take care of shared data
* if this is a shared handle
{
struct _WapiHandle_mutex *mut = (struct _WapiHandle_mutex *)handle_info;
+#ifdef PTHREAD_POINTER_ID
+ g_print ("own: %5d:%5p, count: %5u", mut->pid, mut->tid,
+ mut->recursion);
+#else
g_print ("own: %5d:%5ld, count: %5u", mut->pid, mut->tid,
mut->recursion);
+#endif
}
struct _WapiHandleOps _wapi_namedmutex_ops = {