Blame SOURCES/threads-2.21-Upgrade-to-2.22.patch

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