The handle mutexes aren't used with shared handle types, so don't try and
authorDick Porter <dick@acm.org>
Mon, 4 Apr 2005 10:46:38 +0000 (10:46 -0000)
committerDick Porter <dick@acm.org>
Mon, 4 Apr 2005 10:46:38 +0000 (10:46 -0000)
destroy them.

svn path=/branches/dick/io-layer-no-daemon/; revision=42507

mono/io-layer/handles.c
mono/io-layer/mutexes.c

index c388ba1d60ac701704b278738c637bbc23ded37e..81df0d8215f7d03addcb68bb7138baea40303ecb 100644 (file)
@@ -883,6 +883,8 @@ void _wapi_handle_unref (gpointer handle)
 #endif
        
        if(destroy==TRUE) {
+               WapiHandleType type = _wapi_private_handles[idx].type;
+
 #ifdef DEBUG
                g_message ("%s: Destroying handle %p", __func__, handle);
 #endif
@@ -894,16 +896,18 @@ void _wapi_handle_unref (gpointer handle)
 
                _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
index 7655d034ceaf82edfdfc0e82cc8bdab4349ee462..6ab38fcfd5304102051a1f2a89bf26e40c88925a 100644 (file)
@@ -43,8 +43,13 @@ void _wapi_mutex_details (gpointer handle_info)
 {
        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 = {