527634
From a0eaa97e59b5b2ad8e2a83f8509da3787ff4b4bf Mon Sep 17 00:00:00 2001
527634
From: Jitka Plesnikova <jplesnik@redhat.com>
527634
Date: Thu, 24 May 2018 11:32:01 +0200
527634
Subject: [PATCH] Upgrade to 2.22
527634
527634
---
527634
 lib/threads.pm | 29 ++++++++++++++++++++++++++++-
527634
 threads.xs     |  4 ++++
527634
 2 files changed, 32 insertions(+), 1 deletion(-)
527634
527634
diff --git a/lib/threads.pm b/lib/threads.pm
527634
index 2eb926a..1b99567 100644
527634
--- a/lib/threads.pm
527634
+++ b/lib/threads.pm
527634
@@ -5,7 +5,7 @@ use 5.008;
527634
 use strict;
527634
 use warnings;
527634
 
527634
-our $VERSION = '2.21';      # remember to update version in POD!
527634
+our $VERSION = '2.22';      # remember to update version in POD!
527634
 my $XS_VERSION = $VERSION;
527634
 $VERSION = eval $VERSION;
527634
 
527634
@@ -937,6 +937,33 @@ C<chdir()>) will affect all the threads in the application.
527634
 On MSWin32, each thread maintains its own the current working directory
527634
 setting.
527634
 
527634
+=item Locales
527634
+
527634
+Prior to Perl 5.28, locales could not be used with threads, due to various
527634
+race conditions.  Starting in that release, on systems that implement
527634
+thread-safe locale functions, threads can be used, with some caveats.
527634
+This includes Windows starting with Visual Studio 2005, and systems compatible
527634
+with POSIX 2008.  See L<perllocale/Multi-threaded operation>.
527634
+
527634
+Each thread (except the main thread) is started using the C locale.  The main
527634
+thread is started like all other Perl programs; see L<perllocale/ENVIRONMENT>.
527634
+You can switch locales in any thread as often as you like.
527634
+
527634
+If you want to inherit the parent thread's locale, you can, in the parent, set
527634
+a variable like so:
527634
+
527634
+    $foo = POSIX::setlocale(LC_ALL, NULL);
527634
+
527634
+and then pass to threads->create() a sub that closes over C<$foo>.  Then, in
527634
+the child, you say
527634
+
527634
+    POSIX::setlocale(LC_ALL, $foo);
527634
+
527634
+Or you can use the facilities in L<threads::shared> to pass C<$foo>;
527634
+or if the environment hasn't changed, in the child, do
527634
+
527634
+    POSIX::setlocale(LC_ALL, "");
527634
+
527634
 =item Environment variables
527634
 
527634
 Currently, on all platforms except MSWin32, all I<system> calls (e.g., using
527634
diff --git a/threads.xs b/threads.xs
527634
index 4e9e31f..3da9165 100644
527634
--- a/threads.xs
527634
+++ b/threads.xs
527634
@@ -580,6 +580,8 @@ S_ithread_run(void * arg)
527634
     S_set_sigmask(&thread->initial_sigmask);
527634
 #endif
527634
 
527634
+    thread_locale_init();
527634
+
527634
     PL_perl_destruct_level = 2;
527634
 
527634
     {
527634
@@ -665,6 +667,8 @@ S_ithread_run(void * arg)
527634
     MUTEX_UNLOCK(&thread->mutex);
527634
     MUTEX_UNLOCK(&MY_POOL.create_destruct_mutex);
527634
 
527634
+    thread_locale_term();
527634
+
527634
     /* Exit application if required */
527634
     if (exit_app) {
527634
         (void)S_jmpenv_run(aTHX_ 2, thread, NULL, &exit_app, &exit_code);
527634
-- 
527634
2.14.3
527634