Skip to content

Commit

Permalink
Make ENV_LOCK reentrant
Browse files Browse the repository at this point in the history
This is in preparation for future commits
  • Loading branch information
khwilliamson committed Jul 1, 2024
1 parent 843e7e3 commit 677ac6e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions embedvar.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions intrpvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,7 @@ PERLVAR(I, regex_padav, AV *) /* All regex objects, indexed via the
PERLVAR(I, stashpad, HV **) /* for CopSTASH */
PERLVARI(I, stashpadmax, PADOFFSET, 64)
PERLVARI(I, stashpadix, PADOFFSET, 0)
PERLVARI(I, env_mutex_depth, int, 0) /* Emulate general semaphore */
#endif

#ifdef USE_REENTRANT_API
Expand Down
3 changes: 2 additions & 1 deletion makedef.pl
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@ sub readvar {
PL_regex_padav
PL_dollarzero_mutex
PL_env_mutex
PL_hints_mutex
PL_env_mutex_depth
PL_hints_mutex
PL_locale_mutex
PL_locale_mutex_depth
PL_my_ctx_mutex
Expand Down
9 changes: 7 additions & 2 deletions perl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7065,8 +7065,13 @@ typedef struct am_table_short AMTS;
#endif

#ifdef USE_THREADS
# define ENV_LOCK PERL_WRITE_LOCK(&PL_env_mutex)
# define ENV_UNLOCK PERL_WRITE_UNLOCK(&PL_env_mutex)
# define ENV_LOCK PERL_REENTRANT_LOCK("env", \
&PL_env_mutex, \
PL_env_mutex_depth, \
1)
# define ENV_UNLOCK PERL_REENTRANT_UNLOCK("env", \
&PL_env_mutex, \
PL_env_mutex_depth)
# 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)
Expand Down
4 changes: 4 additions & 0 deletions sv.c
Original file line number Diff line number Diff line change
Expand Up @@ -16240,6 +16240,10 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
PL_less_dicey_locale_buf = NULL;
PL_less_dicey_locale_bufsize = 0;
#endif
#ifdef USE_THREADS
assert(PL_env_mutex_depth <= 0);
PL_env_mutex_depth = 0;
#endif

/* Unicode inversion lists */

Expand Down

0 comments on commit 677ac6e

Please sign in to comment.