perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: [mp2] pool object dependant methods insanity
Date Fri, 24 Dec 2004 19:46:08 GMT
while I can easily reproduce the problem with 
APR::Bucket::alloc_create(APR::Pool->new);
the case with setaside is not clear. I've tried the following:

Index: t/lib/TestAPRlib/bucket.pm
===================================================================
--- t/lib/TestAPRlib/bucket.pm  (revision 123293)
+++ t/lib/TestAPRlib/bucket.pm  (working copy)
@@ -14,7 +14,7 @@
  use APR::BucketType ();

  sub num_of_tests {
-    return 18;
+    return 20;
  }

  sub test {
@@ -160,12 +160,33 @@
          $data =~ s/^..../BBBB/;
          $b->read(my $read);
          ok !t_cmp($read, $data,
-                 "data inside the setaside bucket is uaffected by " .
+                 "data inside the setaside bucket is unaffected by " .
                   "changes to the Perl variable it's created from");
          $b->destroy;
      }

+    # setaside + alloc_create on out-of-scope pools
+    {
+        my $data = "A" x 10;
+        my $orig = $data;
+        #$ba = APR::Bucket::alloc_create(APR::Pool->new);
+        my $b = APR::Bucket->new($ba, $data);
+        my $status = $b->setaside(APR::Pool->new);
+        ok t_cmp $status, 0, "setaside status";

+        # try to overwrite the temp pool data
+        require APR::Table;
+        my $table = APR::Table::make(APR::Pool->new, 50);
+        $table->set($_ => $_) for 'aa'..'za';
+
+        # now test that we are still OK
+        $b->read(my $read);
+        ok !t_cmp($read, $data,
+                 "data inside the setaside bucket is unaffected by " .
+                 "changes to the Perl variable it's created from");
+        $b->destroy;
+    }
+
      APR::Bucket::alloc_destroy($ba);

  }

but it doesn't break. Further looking at the source code,

   $b->setaside(APR::Pool->new);

doesn't replace $b to a new bucket allocation. I think this is why I can't 
reproduce the problem.

Also it looks like we aren't handling scopes:

modperl_bucket.c:

     /* XXX: need to deal with PerlInterpScope */
#ifdef USE_ITHREADS
     svbucket->perl = aTHX;
#endif

but if we handle them we may need to tie an enourmous amount of perl 
interpreters just to deal with each bucket. That sounds a like a bad 
design flow. (which affects pool cleanups as well).




-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message