summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pod/perlmod.pod3
-rw-r--r--sv.c3
2 files changed, 4 insertions, 2 deletions
diff --git a/pod/perlmod.pod b/pod/perlmod.pod
index 53f3d21c65..63f0be9d2c 100644
--- a/pod/perlmod.pod
+++ b/pod/perlmod.pod
@@ -581,6 +581,9 @@ Like C<CLONE>, C<CLONE_SKIP> is called once per package; however, it is
called just before cloning starts, and in the context of the parent
thread. If it returns a true value, then no objects of that class will
be cloned; or rather, they will be copied as unblessed, undef values.
+For example: if in the parent there are two references to a single blessed
+hash, then in the child there will be two references to a single undefined
+scalar value instead.
This provides a simple mechanism for making a module threadsafe; just add
C<sub CLONE_SKIP { 1 }> at the top of the class, and C<DESTROY()> will be
now only be called once per object. Of course, if the child thread needs
diff --git a/sv.c b/sv.c
index 35fc90d47d..f125409ced 100644
--- a/sv.c
+++ b/sv.c
@@ -10048,8 +10048,7 @@ Perl_sv_dup(pTHX_ const SV *sstr, CLONE_PARAMS* param)
/* don't clone objects whose class has asked us not to */
if (SvOBJECT(sstr) && ! (SvFLAGS(SvSTASH(sstr)) & SVphv_CLONEABLE)) {
- SvFLAGS(dstr) &= ~SVTYPEMASK;
- SvOBJECT_off(dstr);
+ SvFLAGS(dstr) = 0;
return dstr;
}