2004-07-05 Dick Porter <dick@ximian.com>
authorDick Porter <dick@acm.org>
Mon, 5 Jul 2004 15:29:12 +0000 (15:29 -0000)
committerDick Porter <dick@acm.org>
Mon, 5 Jul 2004 15:29:12 +0000 (15:29 -0000)
* mutexes.c (mutex_ops_init): Make the named mutex mutex sharable.

* daemon.c (unref_handle): Only destroy a handle if all processes
have released it, not just the current one.  Fixes bug 60887.

svn path=/branches/mono-1-0/mono/; revision=30747

mono/io-layer/ChangeLog
mono/io-layer/daemon.c
mono/io-layer/mutexes.c

index 5b19c8ceadfd8761e41a8f63644ebc561fc56461..ff2f2bca8f48cefe58a3d59c865fd5075c691ae4 100644 (file)
@@ -1,3 +1,10 @@
+2004-07-05  Dick Porter  <dick@ximian.com>
+
+       * mutexes.c (mutex_ops_init): Make the named mutex mutex sharable.
+
+       * daemon.c (unref_handle): Only destroy a handle if all processes
+       have released it, not just the current one.  Fixes bug 60887.
+
 2004-06-24  Dick Porter  <dick@ximian.com>
 
        * mutexes.c: Indicate when a named mutex was reused
index 746fba49d177511d45afdceaec565001489b8a43..62aa75ce1f335d8a18b7e0fcbc90aa92ad9791c5 100644 (file)
@@ -340,16 +340,14 @@ static gboolean unref_handle (ChannelData *channel_data, guint32 handle)
                   channel_data->open_handles[handle]);
 #endif
 
-       if(channel_data->open_handles[handle]==0) {
-               /* This client has released the handle */
-               destroy=TRUE;
-       }
-       
-       if(_wapi_shared_data[segment]->handles[idx].ref==0) {
+       if (_wapi_shared_data[segment]->handles[idx].ref == 0) {
                gboolean was_file;
                dev_t device = 0;
                ino_t inode = 0;
                
+               /* This client has released the handle */
+               destroy=TRUE;
+       
                if (channel_data->open_handles[handle]!=0) {
                        g_warning (G_GNUC_PRETTY_FUNCTION ": per-process open_handles mismatch, set to %d, should be 0", 
                                        channel_data->open_handles[handle]);
index ee736aac2c21064efe177cbec0372274c3185517..ee10921578aea85b51a46f531f01034c8ec1fef6 100644 (file)
@@ -23,9 +23,8 @@
 #undef DEBUG
 
 /* This is used to serialise mutex creation when names are given
- * (FIXME: make it process-shared)
  */
-static mono_mutex_t named_mutex_mutex = MONO_MUTEX_INITIALIZER;
+static mono_mutex_t named_mutex_mutex;
 
 static void mutex_close_shared (gpointer handle);
 static void mutex_signal(gpointer handle);
@@ -44,6 +43,23 @@ static mono_once_t mutex_ops_once=MONO_ONCE_INIT;
 
 static void mutex_ops_init (void)
 {
+       int thr_ret;
+#if defined(_POSIX_THREAD_PROCESS_SHARED) && _POSIX_THREAD_PROCESS_SHARED != -1
+       pthread_mutexattr_t mutex_shared_attr;
+
+       thr_ret = mono_mutexattr_init (&mutex_shared_attr);
+       g_assert (thr_ret == 0);
+
+       thr_ret = mono_mutexattr_setpshared (&mutex_shared_attr,
+                                            PTHREAD_PROCESS_SHARED);
+       g_assert (thr_ret == 0);
+
+       thr_ret = mono_mutex_init (&named_mutex_mutex, &mutex_shared_attr);
+       g_assert (thr_ret == 0);
+#else
+       thr_ret = mono_mutex_init (&named_mutex_mutex, NULL);
+#endif
+
        _wapi_handle_register_capabilities (WAPI_HANDLE_MUTEX,
                                            WAPI_HANDLE_CAP_WAIT |
                                            WAPI_HANDLE_CAP_SIGNAL |