diff options
author | Karl Williamson <khw@cpan.org> | 2020-12-01 07:17:21 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2020-12-19 22:00:29 -0700 |
commit | 57d4826ad702b8c483b826af1c82f52ce64651ff (patch) | |
tree | 5a444073079a27a71358f810d54fc2dc726a6abd | |
parent | 7510ca24a0ab79a6cf9eb76f13117b4e4d18051e (diff) | |
download | perl-57d4826ad702b8c483b826af1c82f52ce64651ff.tar.gz |
perl.h: Add capability for many-reader ENV mutex locking
There are several places where there could be a problem in the
environment were changed by another thread when a function is executing,
but otherwise if another thread were reading the environment at the same
time, there isn't a problem. This adds mutex for that situation.
Future commits will take advantage of it.
-rw-r--r-- | perl.h | 24 | ||||
-rw-r--r-- | perlvars.h | 2 |
2 files changed, 13 insertions, 13 deletions
@@ -7003,19 +7003,19 @@ cannot have changed since the precalculation. #endif /* !USE_LOCALE_NUMERIC */ #ifdef USE_ITHREADS - /* On some platforms it would be safe to use a read/write mutex with many - * readers possible at the same time. On other platforms, notably IBM ones, - * subsequent getenv calls destroy earlier ones. Those platforms would not - * be able to handle simultaneous getenv calls */ -# define ENV_LOCK MUTEX_LOCK(&PL_env_mutex) -# define ENV_UNLOCK MUTEX_UNLOCK(&PL_env_mutex) -# define ENV_INIT MUTEX_INIT(&PL_env_mutex); -# define ENV_TERM MUTEX_DESTROY(&PL_env_mutex); +# define ENV_LOCK PERL_WRITE_LOCK(&PL_env_mutex) +# define ENV_UNLOCK PERL_WRITE_UNLOCK(&PL_env_mutex) +# define ENV_READ_LOCK PERL_READ_LOCK(&PL_env_mutex) +# define ENV_READ_UNLOCK PERL_READ_UNLOCK(&PL_env_mutex) +# define ENV_INIT PERL_RW_MUTEX_INIT(&PL_env_mutex) +# define ENV_TERM PERL_RW_MUTEX_DESTROY(&PL_env_mutex) #else -# define ENV_LOCK NOOP -# define ENV_UNLOCK NOOP -# define ENV_INIT NOOP -# define ENV_TERM NOOP +# define ENV_LOCK NOOP +# define ENV_UNLOCK NOOP +# define ENV_READ_LOCK NOOP +# define ENV_READ_UNLOCK NOOP +# define ENV_INIT NOOP +# define ENV_TERM NOOP #endif #ifndef PERL_NO_INLINE_FUNCTIONS diff --git a/perlvars.h b/perlvars.h index 1bbe5e3ed3..3bfd46fe94 100644 --- a/perlvars.h +++ b/perlvars.h @@ -104,7 +104,7 @@ PERLVARI(G, mmap_page_size, IV, 0) #if defined(USE_ITHREADS) PERLVAR(G, hints_mutex, perl_mutex) /* Mutex for refcounted he refcounting */ -PERLVAR(G, env_mutex, perl_mutex) /* Mutex for accessing ENV */ +PERLVAR(G, env_mutex, perl_RnW1_mutex_t) /* Mutex for accessing ENV */ PERLVAR(G, locale_mutex, perl_mutex) /* Mutex related to locale handling */ # ifndef USE_THREAD_SAFE_LOCALE PERLVAR(G, lc_numeric_mutex, perl_mutex) /* Mutex for switching LC_NUMERIC */ |