You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-cvs@httpd.apache.org by jo...@apache.org on 2009/02/14 00:27:32 UTC

svn commit: r744281 - /httpd/apreq/trunk/glue/perl/xsbuilder/apreq_xs_postperl.h

Author: joes
Date: Fri Feb 13 23:27:31 2009
New Revision: 744281

URL: http://svn.apache.org/viewvc?rev=744281&view=rev
Log:
revert, yes mortal is correct here

Modified:
    httpd/apreq/trunk/glue/perl/xsbuilder/apreq_xs_postperl.h

Modified: httpd/apreq/trunk/glue/perl/xsbuilder/apreq_xs_postperl.h
URL: http://svn.apache.org/viewvc/httpd/apreq/trunk/glue/perl/xsbuilder/apreq_xs_postperl.h?rev=744281&r1=744280&r2=744281&view=diff
==============================================================================
--- httpd/apreq/trunk/glue/perl/xsbuilder/apreq_xs_postperl.h (original)
+++ httpd/apreq/trunk/glue/perl/xsbuilder/apreq_xs_postperl.h Fri Feb 13 23:27:31 2009
@@ -250,13 +250,13 @@
     }
 
     if (obj != Nullsv)
-        sv_setsv(*hv_fetch(data, "_r",   2, 1), newRV_inc(obj));
+        sv_setsv(*hv_fetch(data, "_r",   2, 1), sv_2mortal(newRV_inc(obj)));
     sv_setiv(*hv_fetch(data, "rc",   2, 1), rc);
     sv_setpv(*hv_fetch(data, "file", 4, 1), CopFILE(PL_curcop));
     sv_setiv(*hv_fetch(data, "line", 4, 1), CopLINE(PL_curcop));
     sv_setpv(*hv_fetch(data, "func", 4, 1), func);
 
-    sv_setsv(ERRSV, sv_bless(newRV_noinc((SV*)data), stash));
+    sv_setsv(ERRSV, sv_2mortal(sv_bless(newRV_noinc((SV*)data), stash)));
     Perl_croak(aTHX_ Nullch);
 }
 



Re: svn commit: r744281 - /httpd/apreq/trunk/glue/perl/xsbuilder/apreq_xs_postperl.h

Posted by Joe Schaefer <jo...@yahoo.com>.
----- Original Message ----

> From: Fred Moyer <fr...@redhotpenguin.com>
> To: apreq-dev@httpd.apache.org
> Sent: Friday, February 13, 2009 6:32:48 PM
> Subject: Re: svn commit: r744281 - /httpd/apreq/trunk/glue/perl/xsbuilder/apreq_xs_postperl.h
> 
> On Fri, Feb 13, 2009 at 3:27 PM,  wrote:
> > Author: joes
> > Date: Fri Feb 13 23:27:31 2009
> > New Revision: 744281
> >
> > URL: http://svn.apache.org/viewvc?rev=744281&view=rev
> > Log:
> > revert, yes mortal is correct here
> 
> Could you give a lamens explanation of sv_2mortal for those of us
> aspiring hackers?  I've seen it all over the place in the mod_perl and
> apreq codebase (and perl as well), but haven't ever been able to track
> down what it really does.

Basically it's the C analog of lexically scoped variables. Mortal SV's
are temporary variables, meant to be freed up by perl at the next 
"convenient" point (usually a FREETMPS call).  If you create an SV in
C, and unless you are constructing parts of an object, you probably want
it to be mortal.  Otherwise you wind up creating an internal perl scalar
that has a refcount that never gets decremented and consequently freed.


      

Re: svn commit: r744281 - /httpd/apreq/trunk/glue/perl/xsbuilder/apreq_xs_postperl.h

Posted by Fred Moyer <fr...@redhotpenguin.com>.
On Fri, Feb 13, 2009 at 3:27 PM,  <jo...@apache.org> wrote:
> Author: joes
> Date: Fri Feb 13 23:27:31 2009
> New Revision: 744281
>
> URL: http://svn.apache.org/viewvc?rev=744281&view=rev
> Log:
> revert, yes mortal is correct here

Could you give a lamens explanation of sv_2mortal for those of us
aspiring hackers?  I've seen it all over the place in the mod_perl and
apreq codebase (and perl as well), but haven't ever been able to track
down what it really does.

>
> Modified:
>    httpd/apreq/trunk/glue/perl/xsbuilder/apreq_xs_postperl.h
>
> Modified: httpd/apreq/trunk/glue/perl/xsbuilder/apreq_xs_postperl.h
> URL: http://svn.apache.org/viewvc/httpd/apreq/trunk/glue/perl/xsbuilder/apreq_xs_postperl.h?rev=744281&r1=744280&r2=744281&view=diff
> ==============================================================================
> --- httpd/apreq/trunk/glue/perl/xsbuilder/apreq_xs_postperl.h (original)
> +++ httpd/apreq/trunk/glue/perl/xsbuilder/apreq_xs_postperl.h Fri Feb 13 23:27:31 2009
> @@ -250,13 +250,13 @@
>     }
>
>     if (obj != Nullsv)
> -        sv_setsv(*hv_fetch(data, "_r",   2, 1), newRV_inc(obj));
> +        sv_setsv(*hv_fetch(data, "_r",   2, 1), sv_2mortal(newRV_inc(obj)));
>     sv_setiv(*hv_fetch(data, "rc",   2, 1), rc);
>     sv_setpv(*hv_fetch(data, "file", 4, 1), CopFILE(PL_curcop));
>     sv_setiv(*hv_fetch(data, "line", 4, 1), CopLINE(PL_curcop));
>     sv_setpv(*hv_fetch(data, "func", 4, 1), func);
>
> -    sv_setsv(ERRSV, sv_bless(newRV_noinc((SV*)data), stash));
> +    sv_setsv(ERRSV, sv_2mortal(sv_bless(newRV_noinc((SV*)data), stash)));
>     Perl_croak(aTHX_ Nullch);
>  }
>
>
>
>