Blame SOURCES/threads-shared-1.59-Upgrade-to-1.60.patch

e88f2c
From 2ec58402d05eb12d0b9387963941f1e445d9aa5b Mon Sep 17 00:00:00 2001
e88f2c
From: Jitka Plesnikova <jplesnik@redhat.com>
e88f2c
Date: Fri, 26 Apr 2019 15:00:30 +0200
e88f2c
Subject: [PATCH] Upgrade to 1.60
e88f2c
e88f2c
---
e88f2c
 lib/threads/shared.pm |  4 ++--
e88f2c
 shared.xs             | 39 +++++++++++++++++++++++++++++++++++++++
e88f2c
 2 files changed, 41 insertions(+), 2 deletions(-)
e88f2c
e88f2c
diff --git a/lib/threads/shared.pm b/lib/threads/shared.pm
e88f2c
index f7e5ff8..45ad154 100644
e88f2c
--- a/lib/threads/shared.pm
e88f2c
+++ b/lib/threads/shared.pm
e88f2c
@@ -8,7 +8,7 @@ use Config;
e88f2c
 
e88f2c
 use Scalar::Util qw(reftype refaddr blessed);
e88f2c
 
e88f2c
-our $VERSION = '1.59'; # Please update the pod, too.
e88f2c
+our $VERSION = '1.60'; # Please update the pod, too.
e88f2c
 my $XS_VERSION = $VERSION;
e88f2c
 $VERSION = eval $VERSION;
e88f2c
 
e88f2c
@@ -196,7 +196,7 @@ threads::shared - Perl extension for sharing data structures between threads
e88f2c
 
e88f2c
 =head1 VERSION
e88f2c
 
e88f2c
-This document describes threads::shared version 1.59
e88f2c
+This document describes threads::shared version 1.60
e88f2c
 
e88f2c
 =head1 SYNOPSIS
e88f2c
 
e88f2c
diff --git a/shared.xs b/shared.xs
e88f2c
index d0f7d1e..6cdf094 100644
e88f2c
--- a/shared.xs
e88f2c
+++ b/shared.xs
e88f2c
@@ -115,6 +115,17 @@
e88f2c
  * without the prefix (e.g., sv, tmp or obj).
e88f2c
  */
e88f2c
 
e88f2c
+/* this is lower overhead than warn() and less likely to interfere
e88f2c
+   with other parts of perl (like with the debugger.)
e88f2c
+*/
e88f2c
+#ifdef SHARED_TRACE_LOCKS
e88f2c
+#  define TRACE_LOCK(x) DEBUG_U(x)
e88f2c
+#  define TRACE_LOCKv(x) DEBUG_Uv(x)
e88f2c
+#else
e88f2c
+#  define TRACE_LOCK(x)
e88f2c
+#  define TRACE_LOCKv(x)
e88f2c
+#endif
e88f2c
+
e88f2c
 #define PERL_NO_GET_CONTEXT
e88f2c
 #include "EXTERN.h"
e88f2c
 #include "perl.h"
e88f2c
@@ -211,8 +222,24 @@ recursive_lock_release(pTHX_ recursive_lock_t *lock)
e88f2c
         if (--lock->locks == 0) {
e88f2c
             lock->owner = NULL;
e88f2c
             COND_SIGNAL(&lock->cond);
e88f2c
+            TRACE_LOCK(
e88f2c
+                    PerlIO_printf(Perl_debug_log, "shared lock released %p for %p at %s:%d\n",
e88f2c
+                                  lock, aTHX, CopFILE(PL_curcop), CopLINE(PL_curcop))
e88f2c
+                    );
e88f2c
+        }
e88f2c
+        else {
e88f2c
+            TRACE_LOCKv(
e88f2c
+                    PerlIO_printf(Perl_debug_log, "shared lock unbump %p for %p at %s:%d\n",
e88f2c
+                                  lock, aTHX, CopFILE(PL_curcop), CopLINE(PL_curcop))
e88f2c
+                    );
e88f2c
         }
e88f2c
     }
e88f2c
+    else {
e88f2c
+        TRACE_LOCK(
e88f2c
+                PerlIO_printf(Perl_debug_log, "bad shared lock release %p for %p (owned by %p) at %s:%d\n",
e88f2c
+                               lock, aTHX, lock->owner, CopFILE(PL_curcop), CopLINE(PL_curcop))
e88f2c
+                 );
e88f2c
+    }
e88f2c
     MUTEX_UNLOCK(&lock->mutex);
e88f2c
 }
e88f2c
 
e88f2c
@@ -224,8 +251,16 @@ recursive_lock_acquire(pTHX_ recursive_lock_t *lock, const char *file, int line)
e88f2c
     assert(aTHX);
e88f2c
     MUTEX_LOCK(&lock->mutex);
e88f2c
     if (lock->owner == aTHX) {
e88f2c
+        TRACE_LOCKv(
e88f2c
+                 PerlIO_printf(Perl_debug_log, "shared lock bump %p (%p) at %s:%d\n",
e88f2c
+                               lock, lock->owner, CopFILE(PL_curcop), CopLINE(PL_curcop))
e88f2c
+                 );
e88f2c
         lock->locks++;
e88f2c
     } else {
e88f2c
+        TRACE_LOCK(
e88f2c
+                 PerlIO_printf(Perl_debug_log, "shared lock try %p for %p (owned by %p) at %s:%d\n",
e88f2c
+                               lock, aTHX, lock->owner, CopFILE(PL_curcop), CopLINE(PL_curcop))
e88f2c
+                 );
e88f2c
         while (lock->owner) {
e88f2c
 #ifdef DEBUG_LOCKS
e88f2c
             Perl_warn(aTHX_ " %p waiting - owned by %p %s:%d\n",
e88f2c
@@ -233,6 +268,10 @@ recursive_lock_acquire(pTHX_ recursive_lock_t *lock, const char *file, int line)
e88f2c
 #endif
e88f2c
             COND_WAIT(&lock->cond,&lock->mutex);
e88f2c
         }
e88f2c
+        TRACE_LOCK(
e88f2c
+                 PerlIO_printf(Perl_debug_log, "shared lock got %p at %s:%d\n",
e88f2c
+                               lock, CopFILE(PL_curcop), CopLINE(PL_curcop))
e88f2c
+                 );
e88f2c
         lock->locks = 1;
e88f2c
         lock->owner = aTHX;
e88f2c
 #ifdef DEBUG_LOCKS
e88f2c
-- 
e88f2c
2.20.1
e88f2c