diff options
author | Dick Porter <dick@acm.org> | 2004-07-05 19:29:12 +0400 |
---|---|---|
committer | Dick Porter <dick@acm.org> | 2004-07-05 19:29:12 +0400 |
commit | 254baa76a0fd9abd888207575e85db1ab90a31cd (patch) | |
tree | 335b6cdddf6f2b3657b78edd75ba83e54b1f8c70 | |
parent | ed513a7a08efa93b8db97845df1456779ed792a9 (diff) |
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.
svn path=/branches/mono-1-0/mono/; revision=30747
-rw-r--r-- | mono/io-layer/ChangeLog | 7 | ||||
-rw-r--r-- | mono/io-layer/daemon.c | 10 | ||||
-rw-r--r-- | mono/io-layer/mutexes.c | 20 |
3 files changed, 29 insertions, 8 deletions
diff --git a/mono/io-layer/ChangeLog b/mono/io-layer/ChangeLog index 5b19c8ceadf..ff2f2bca8f4 100644 --- a/mono/io-layer/ChangeLog +++ b/mono/io-layer/ChangeLog @@ -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 diff --git a/mono/io-layer/daemon.c b/mono/io-layer/daemon.c index 746fba49d17..62aa75ce1f3 100644 --- a/mono/io-layer/daemon.c +++ b/mono/io-layer/daemon.c @@ -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]); diff --git a/mono/io-layer/mutexes.c b/mono/io-layer/mutexes.c index ee736aac2c2..ee10921578a 100644 --- a/mono/io-layer/mutexes.c +++ b/mono/io-layer/mutexes.c @@ -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 | |