summaryrefslogtreecommitdiff
path: root/locale.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2021-03-08 05:21:32 -0700
committerKarl Williamson <khw@cpan.org>2022-09-21 14:34:41 -0600
commit1118ec15947427988784e2ab16171203db9b9d3f (patch)
treec5e02999784342a7ead370223561fd631a024add /locale.c
parentdff607ef35caa67235b1379fe58f6c48b130faa6 (diff)
downloadperl-1118ec15947427988784e2ab16171203db9b9d3f.tar.gz
Add POSIX_SETLOCALE_LOCK/UNLOCK
This macro is used to surround raw setlocale() calls so that the return value in a global static buffer can be saved without interference with other threads.
Diffstat (limited to 'locale.c')
-rw-r--r--locale.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/locale.c b/locale.c
index e708f7fd9a..5767da8fc7 100644
--- a/locale.c
+++ b/locale.c
@@ -700,9 +700,11 @@ S_my_querylocale_i(pTHX_ const unsigned int index)
DEBUG_Lv(PerlIO_printf(Perl_debug_log, "my_querylocale_i(%s) on %p\n",
category_names[index], cur_obj));
- if (cur_obj == LC_GLOBAL_LOCALE) {
+ if (cur_obj == LC_GLOBAL_LOCALE) {
+ POSIX_SETLOCALE_LOCK;
retval = posix_setlocale(category, NULL);
- }
+ POSIX_SETLOCALE_UNLOCK;
+ }
else {
# ifdef USE_QUERYLOCALE
@@ -1212,6 +1214,7 @@ S_emulate_setlocale_i(pTHX_
# ifdef USE_PL_CURLOCALES
if (entry_obj == LC_GLOBAL_LOCALE) {
+
/* Here, we are back in the global locale. We may never have
* set PL_curlocales. If the locale change had succeeded, the
* code would have then set them up, but since it didn't, do so
@@ -1219,11 +1222,13 @@ S_emulate_setlocale_i(pTHX_
* but tis is defensive coding. The system setlocale() returns
* the desired information. This will calculate LC_ALL's entry
* only on the final iteration */
+ POSIX_SETLOCALE_LOCK;
for (PERL_UINT_FAST8_T i = 0; i < NOMINAL_LC_ALL_INDEX; i++) {
update_PL_curlocales_i(i,
posix_setlocale(categories[i], NULL),
RECALCULATE_LC_ALL_ON_FINAL_INTERATION);
}
+ POSIX_SETLOCALE_UNLOCK;
}
# endif