As I've mentioned in another thread [EMAIL PROTECTED] adds CLONE_SKIP, so much needed by mod_perl. With the patch I've just posted none of the mp2 objects is cloned when a new thread is started. That means that a thread won't be able to use any of the objects created outside of the thread. Which is good, but it creates a problem with Apache-Test, which relies on the tied STDOUT to run ok()'s. Inside the thread any print on the tied STDOUT will fail, since it's tied to an invalid object. We can't retie it, since we don't have a valid $r and we can't create one.

So we can use Apache::TestToString, but the tied buffer needs to be shared:

Index: Apache-Test/lib/Apache/Test.pm
===================================================================
--- Apache-Test/lib/Apache/Test.pm      (revision 161957)
+++ Apache-Test/lib/Apache/Test.pm      (working copy)
@@ -506,8 +493,13 @@

 package Apache::TestToString;

+use Config;
 sub TIEHANDLE {
     my $string = "";
+    if ($] >= 5.008 && $Config{useithreads} && $INC{'threads.pm'}) {
+        require threads::shared;
+        $string = &threads::shared::share(\$string);
+    }
     bless \$string;
 }


and then we can write things like:

sub handler {
    my $r = shift;

    Apache::TestToString->start;

    plan tests => $tests;

    read_test();
    threads->new(\&read_test)->join() for 1..$threads;
    read_test();

    $r->print(Apache::TestToString->finish);

    Apache2::Const::OK;
}

Clumsy, but at least it almost works.

I just need to figure out why Test::Builder doesn't do proper sub-test counting :9(

Test output counter mismatch [test 32]
ok 13 - tid: 0: pass 1:
Test output counter mismatch [test 33]
ok 14 - tid: 0: pass 2:
Test output counter mismatch [test 34]
ok 15 - tid: 0: pass 1:
...

even though threads.pm was loaded before Test::Builder.

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

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to