You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Plymouth Rock <Tr...@newmail.ru> on 2005/08/03 05:04:54 UTC

win32, mod_perl/2.0.1, Apache/2.0.54 - ithreads problem

 I'd using ithreads on ActivePerl 5.8.7 and Apache/2.0.54 (Win32). All
scripts
with ithreads did working excellent. Since I've installed mod_perl/2.0.1
with
'ppm install', those scripts have ceased to work (there's an initial
HTML-table's
dumping only). Due to I couldn't find another ways to demonstrate several
processes working in pseudo-parallel (on win32), I was forced to write CGI-
scripts just for a browser, not for shell. That is why I print out a
multicolumn
table.

 What there are on my PC:
 w2k SP3
 MSIE6 SP1
 Apache/2.0.54 (Win32)
 mod_ssl/2.0.54
 OpenSSL/0.9.7g
 PHP/4.3.11
 mod_perl/2.0.1
 Perl/v5.8.7
 I downloaded the pre-compiled binary file that is about 30 Mb from:
 http://apache.tsuren.net/perl/win32-bin/Perl-5.8-win32-bin-0.10.exe
 It's the "All in one packages": Apache, ActivePerl, mod_perl, mod_php and
so on.

 Paths:
 C:\Perl\bin\
 C:\Program Files\Apache Group\Apache2\bin\


 I'm writing and running CGI-scripts under MSIE6 that use the $|++
buffering,
the threads module and so on. Here are all the modules I'm using within any
single thread-script:

use strict;
use warnings;
use Time::HiRes;
use threads;
use threads::shared;
use Thread::Queue;

 Also I've checked up and modified paths and some directives in the
httpd.conf according to mod_perl 2.0 docs:

###################################################################
<IfModule mpm_winnt.c>
ThreadsPerChild 4
MaxRequestsPerChild  0
</IfModule>

LoadFile "C:/Perl/bin/perl58.dll"
LoadModule perl_module modules/mod_perl.so

DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs"

<Directory "C:/Program Files/Apache Group/Apache2/htdocs">

Alias /modperl/ "C:/Program Files/Apache Group/Apache2/modperl/"

Alias /perl/ "/Apache2/perl/"
  <Location /perl>
     SetHandler perl-script
     PerlResponseHandler ModPerl::Registry
     Options +ExecCGI
     PerlOptions +ParseHeaders
  </Location>

ScriptAlias /cgi-bin/ "C:/Program Files/Apache Group/Apache2/cgi-bin/"

<Directory "C:/Program Files/Apache Group/Apache2/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

<IfModule mod_perl.c>
    Include conf/perl.conf
</IfModule>
###################################################################

 Also I made like that in the perl.conf.

 A script was placed to C:/Program Files/Apache Group/Apache2/perl/
dir and running from MSIE as http://localhost/perl/myscript.pl with no
shebang!

 Now the error.log says:

Sat Jul 30 16:33:19 2005] [notice] Child 1048: Child process is running
[Sat Jul 30 16:33:19 2005] [notice] Child 1048: Acquired the start mutex.
[Sat Jul 30 16:33:19 2005] [notice] Child 1048: Starting 4 worker threads.
Variable "$q_letters" will not stay shared at (eval 75) line 75.
Variable "@threads" will not stay shared at (eval 75) line 73.
...and so on.

 When I'd running that script with Perl.exe interpreter from cgi-bin dir
and #!C:\Perl\bin\perl -w shebang, there weren't any errors and warning
messages.

 Here is an example of what is the $q_letters variable:
my $q_letters = new Thread::Queue;
$q_letters->enqueue('a','b','c',   'd','e','f',   'g','h','i');

 When I'm running the same script just in a shell, I seeing a HTML-table's
dumpimg again and no more, although the CPU still doing something hidden for
certain period.
 Also I'd looking at processes and seeing something like leak of memory:
Apache.exe did growing up to 45 Mb after that w2k had displayed alert msg
about "virtual memory is almost up".

 What's wrong? How to solve the problem of running win32-CGI-thread-scripts
on mod_perl 2.0 and Apache2? Is mod_perl 2.0 intended for using the win32's
threads module and the rest I using?
 If you're interesting, I'll post my script (3 kb) here.

 Thanx.

 P.S.: While I'd writing the message I nevertheless could wait until
a script shows some incorrect results in MSIE (about 10 min!!! later after
script was started).


Re: win32, mod_perl/2.0.1, Apache/2.0.54 - ithreads problem

Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Wed, 3 Aug 2005, Plymouth Rock wrote:

> I'd using ithreads on ActivePerl 5.8.7 and Apache/2.0.54 (Win32).
[ ... ]
> A script was placed to C:/Program Files/Apache Group/Apache2/perl/
> dir and running from MSIE as http://localhost/perl/myscript.pl with no
> shebang!
>
> Now the error.log says:
>
> Sat Jul 30 16:33:19 2005] [notice] Child 1048: Child process is running
> [Sat Jul 30 16:33:19 2005] [notice] Child 1048: Acquired the start mutex.
> [Sat Jul 30 16:33:19 2005] [notice] Child 1048: Starting 4 worker threads.
> Variable "$q_letters" will not stay shared at (eval 75) line 75.
> Variable "@threads" will not stay shared at (eval 75) line 73.
> ...and so on.

You probably should fix up this problem first about
variables not staying shared in a registry script:

http://perl.apache.org/docs/general/perl_reference/perl_reference.html#my___Scoped_Variable_in_Nested_Subroutines

-- 
best regards,
randy

Re: win32, mod_perl/2.0.1, Apache/2.0.54 - ithreads problem

Posted by Stas Bekman <st...@stason.org>.
> I'm not an expert on ithreads (Stas is the resident
> guru on this), but from messages such as
>  http://marc.theaimsgroup.com/?l=apache-modperl&w=2&r=1&s=threads%3A%3Ashared&q=b 
> 
> there's still issues with these, especially in a mod_perl
> environment.

Try using this modperl2 branch and perl 5.8.7:
http://svn.apache.org/viewcvs.cgi/perl/modperl/branches/clone-skip-unstable/
(this is source)

> Could you post a complete (but minimal) script that
> illustrates the problem you're encountering? From what
> you wrote above, I tried this Registry script:

seconded.

-- 
__________________________________________________________________
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

Re: win32, mod_perl/2.0.1, Apache/2.0.54 - ithreads problem

Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Wed, 3 Aug 2005, Plymouth Rock wrote:

> I'd using ithreads on ActivePerl 5.8.7 and Apache/2.0.54 
> (Win32). All scripts with ithreads did working excellent. 
> Since I've installed mod_perl/2.0.1 with 'ppm install', 
> those scripts have ceased to work (there's an initial 
> HTML-table's dumping only). Due to I couldn't find another 
> ways to demonstrate several processes working in 
> pseudo-parallel (on win32), I was forced to write CGI- 
> scripts just for a browser, not for shell. That is why I 
> print out a multicolumn table.
>
> What there are on my PC:
> w2k SP3
> MSIE6 SP1
> Apache/2.0.54 (Win32)
> mod_ssl/2.0.54
> OpenSSL/0.9.7g
> PHP/4.3.11
> mod_perl/2.0.1
> Perl/v5.8.7
[ ... ]
> I'm writing and running CGI-scripts under MSIE6 that use 
> the $|++ buffering, the threads module and so on. Here are 
> all the modules I'm using within any single thread-script:
>
> use strict;
> use warnings;
> use Time::HiRes;
> use threads;
> use threads::shared;
> use Thread::Queue;
[ ... ]
> A script was placed to C:/Program Files/Apache Group/Apache2/perl/
> dir and running from MSIE as http://localhost/perl/myscript.pl with no
> shebang!

Hi,
    The shebang isn't needed for Registry scripts.

> Now the error.log says:
>
> Sat Jul 30 16:33:19 2005] [notice] Child 1048: Child process is running
> [Sat Jul 30 16:33:19 2005] [notice] Child 1048: Acquired the start mutex.
> [Sat Jul 30 16:33:19 2005] [notice] Child 1048: Starting 4 worker threads.
> Variable "$q_letters" will not stay shared at (eval 75) line 75.
> Variable "@threads" will not stay shared at (eval 75) line 73.
> ...and so on.
>
> When I'd running that script with Perl.exe interpreter from cgi-bin dir
> and #!C:\Perl\bin\perl -w shebang, there weren't any errors and warning
> messages.
>
> Here is an example of what is the $q_letters variable:
> my $q_letters = new Thread::Queue;
> $q_letters->enqueue('a','b','c',   'd','e','f',   'g','h','i');

I'm not an expert on ithreads (Stas is the resident
guru on this), but from messages such as
  http://marc.theaimsgroup.com/?l=apache-modperl&w=2&r=1&s=threads%3A%3Ashared&q=b
there's still issues with these, especially in a mod_perl
environment.

Could you post a complete (but minimal) script that
illustrates the problem you're encountering? From what
you wrote above, I tried this Registry script:
=======================================================
#!D:/Perl/bin/perl
##
##  printenv -- demo CGI program which just prints its environment
##
use strict;
use warnings;
use threads;
use threads::shared;
use Thread::Queue;
my $q_letters = new Thread::Queue;
$q_letters->enqueue('a','b','c',   'd','e','f',   'g','h','i');

print <<"END";
Content-type: text/html

<HTML><HEAD>
<TITLE>Hello</TITLE>
</HEAD><BODY>
<H3>Hello</H3>
</BODY></HTML>
END

===========================================================
and didn't see any messages of the sort you saw in the
error log, nor did the Apache process grow (I'm using
the system that I used to make up the all-in-one
binary you're using).

-- 
best regards,
randy kobes