From: Dave Mitchell Date: Fri, 2 Nov 2007 23:59:27 +0000 (+0000) Subject: [perl #47045] CLONE_SKIP doesn't result in undef copies X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=33de8e4aff58f134481d1a594f7a9734709d8ea5;p=p5sagit%2Fp5-mst-13.2.git [perl #47045] CLONE_SKIP doesn't result in undef copies clarify the documentation on CLONE_SKIP, and ensure that the undef value has all its flags cleared p4raw-id: //depot/perl@32213 --- diff --git a/pod/perlmod.pod b/pod/perlmod.pod index 53f3d21..63f0be9 100644 --- a/pod/perlmod.pod +++ b/pod/perlmod.pod @@ -581,6 +581,9 @@ Like C, C 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 at the top of the class, and C 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 35fc90d..f125409 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; }