Blob Blame History Raw
From 7b3443d31f11c15859593e5b710c301795a6de01 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Thu, 8 Jun 2017 11:06:39 +1000
Subject: [PATCH] [perl #131221] sv_dup/sv_dup_inc are only available under
 threads
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Petr Písař <ppisar@redhat.com>
---
 ext/PerlIO-via/via.xs | 42 +++++++++++++++++++++++-------------------
 1 file changed, 23 insertions(+), 19 deletions(-)

diff --git a/ext/PerlIO-via/via.xs b/ext/PerlIO-via/via.xs
index 61953c8..d91c685 100644
--- a/ext/PerlIO-via/via.xs
+++ b/ext/PerlIO-via/via.xs
@@ -619,26 +619,30 @@ static PerlIO *
 PerlIOVia_dup(pTHX_ PerlIO * f, PerlIO * o, CLONE_PARAMS * param,
 	      int flags)
 {
-    if ((f = PerlIOBase_dup(aTHX_ f, o, param, flags)) && param) {
-	/* For a non-interpreter dup stash and obj have been set up
-	   by the implied push.
-
-           But if this is a clone for a new interpreter we need to
-           translate the objects to their dups.
-	 */
-
-        PerlIOVia *fs = PerlIOSelf(f, PerlIOVia);
-        PerlIOVia *os = PerlIOSelf(o, PerlIOVia);
-
-        fs->obj = sv_dup_inc(os->obj, param);
-        fs->stash = (HV*)sv_dup((SV*)os->stash, param);
-        fs->var = sv_dup_inc(os->var, param);
-        fs->cnt = os->cnt;
-
-        /* fh, io, cached CVs left as NULL, PerlIOVia_method()
-           will reinitialize them if needed */
+    if ((f = PerlIOBase_dup(aTHX_ f, o, param, flags))) {
+#ifdef USE_ITHREADS
+        if (param) {
+            /* For a non-interpreter dup stash and obj have been set up
+               by the implied push.
+
+               But if this is a clone for a new interpreter we need to
+               translate the objects to their dups.
+            */
+
+            PerlIOVia *fs = PerlIOSelf(f, PerlIOVia);
+            PerlIOVia *os = PerlIOSelf(o, PerlIOVia);
+
+            fs->obj = sv_dup_inc(os->obj, param);
+            fs->stash = (HV*)sv_dup((SV*)os->stash, param);
+            fs->var = sv_dup_inc(os->var, param);
+            fs->cnt = os->cnt;
+
+            /* fh, io, cached CVs left as NULL, PerlIOVia_method()
+               will reinitialize them if needed */
+        }
+#endif
+        /* for a non-threaded dup fs->obj and stash should be set by _pushed() */
     }
-    /* for a non-threaded dup fs->obj and stash should be set by _pushed() */
 
     return f;
 }
-- 
2.9.4