This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #37919] Blessed scalar refs with threads::shared
authorJerry D. Hedden <jdhedden@cpan.org>
Tue, 13 Dec 2005 15:11:20 +0000 (07:11 -0800)
committerDave Mitchell <davem@fdisolutions.com>
Wed, 14 Dec 2005 12:44:20 +0000 (12:44 +0000)
From:  "Jerry D. Hedden" (via RT) <perlbug-followup@perl.org>
Message-Id:  <rt-3.0.11-37919-125690.15.3722450337035@perl.org>

Unlike arrays and hashes, coping blessed refs to shared scalars left
the copy unblessed

p4raw-id: //depot/perl@26350

MANIFEST
ext/threads/shared/shared.xs

index 5ce2848..563d283 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -976,6 +976,7 @@ ext/threads/shared/shared.xs        thread shared variables
 ext/threads/shared/t/0nothread.t       Tests for basic shared array functionality.
 ext/threads/shared/t/av_refs.t Tests for arrays containing references
 ext/threads/shared/t/av_simple.t       Tests for basic shared array functionality.
 ext/threads/shared/t/0nothread.t       Tests for basic shared array functionality.
 ext/threads/shared/t/av_refs.t Tests for arrays containing references
 ext/threads/shared/t/av_simple.t       Tests for basic shared array functionality.
+ext/threads/shared/t/blessed.t Test blessed shared variables
 ext/threads/shared/t/cond.t    Test condition variables
 ext/threads/shared/t/disabled.t        Test threads::shared when threads are disabled.
 ext/threads/shared/t/hv_refs.t Test shared hashes containing references
 ext/threads/shared/t/cond.t    Test condition variables
 ext/threads/shared/t/disabled.t        Test threads::shared when threads are disabled.
 ext/threads/shared/t/hv_refs.t Test shared hashes containing references
index aa1dcf2..c902683 100644 (file)
@@ -378,6 +378,13 @@ Perl_sharedsv_associate(pTHX_ SV **psv, SV *ssv, shared_sv *data)
                                &sharedsv_scalar_vtbl, (char *)data, 0);
                mg->mg_flags |= (MGf_COPY|MGf_DUP);
                SvREFCNT_inc(ssv);
                                &sharedsv_scalar_vtbl, (char *)data, 0);
                mg->mg_flags |= (MGf_COPY|MGf_DUP);
                SvREFCNT_inc(ssv);
+               if(SvOBJECT(ssv)) {
+                 STRLEN len;
+                 char* stash_ptr = SvPV((SV*) SvSTASH(ssv), len);
+                 HV* stash = gv_stashpvn(stash_ptr, len, TRUE);
+                 SvOBJECT_on(sv);
+                 SvSTASH_set(sv, (HV*)SvREFCNT_inc(stash));
+               }
            }
            break;
        }
            }
            break;
        }