RE: Modperl/Apache deficiencies... Memory usage.
I understand that. :) And that was something that I had to learn myself. :) It's a BAD thing when suddenly your httpd process takes up 100 MB. :) It's just that it sounded like Shane was saying that his httpds were starting OUT at 4 to 6 MB. That sounded a little unusual to me but then again, I've pared down my httpd config so that I don't have things in that I don't need. I'm just curious as to what he has in there. -- Jeff Stuart [EMAIL PROTECTED] -Original Message- From: Gunther Birznieks [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 18, 2000 1:24 AM To: [EMAIL PROTECTED] Subject: RE: Modperl/Apache deficiencies... Memory usage. If you aren't careful with your programming, an apache HTTPD can always grow pretty quickly because Perl never releases the RAM it allocates previously. While it does that reference count garbage collection, that is internal to the RAM that was allocated. Let's say you need to sort a record set returned from a DBI call in an unusual perl-like way. If you do this "in memory", you need an array to hold the entire recordset in memory at once. If you do this, though, you will allocate the RAM for that one request that sorted the array and then the HTTPD will remain that size forever. Keeping the higher RAM allocation is good for performance if you have the RAM of course. So this is one of those design tradeoffs. And Perl was not really written to be a persistent language, so again, the tradeoff of operational speed seems to make sense versus persistent memory usage. Later, Gunther At 12:25 AM 4/18/00 -0400, Jeff Stuart wrote: Shane, question for you. No offense intended here at all but what do you have in your apache servers (other than mod_perl) that use 4 to 6 MB? I've got one server that I'm working on that handles close 1 Mil hits per day than runs WITH mod_perl that uses 4 to 6 MB. ;-) Without mod_perl, it takes up around 500 to 800 KB. Now on another server my mod_perl server uses about 13 Mb per but it's my devel machine so I've got a lot of stuff loaded that I wouldn't have in a production server. -- Jeff Stuart [EMAIL PROTECTED] -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Saturday, April 15, 2000 6:46 PM To: Perrin Harkins Cc: [EMAIL PROTECTED] Subject: Re: Modperl/Apache deficiencies... Memory usage. Your apache processes would be the size of a stock apache process, like 4-6M or so, and you would have 1 process that would be 25MB or so that would have all your registry in it. __ Gunther Birznieks ([EMAIL PROTECTED]) Extropia - The Web Technology Company http://www.extropia.com/
[RFC] Do Not Run Everything on One mod_perl Server
Let's assume that you have two different sets of scripts/code which have a little or nothing in common at all (different modules, no base code sharing), the basic mod_perl process before the code have been loaded of three Mbytes and each code base adds ten Mbytes when loaded. Which makes each process 23Mb in size when all the code gets loaded. Assuming that we have 230 Mb of RAM available to the mod_perl server, the memory limitation allows us to run ten mod_perl servers (23Mb*10=230Mb). Now consider this practical decision. Since we have recognized that the code sets are very distinct in nature and there is no significant memory sharing in place, the wise thing to do is to split the two code sets between two mod_perl servers (a single mod_perl server actually is a set of the parent process and a number of the child processes). So instead of running everything on one server, now we move the second code set onto another mod_perl server. At this point we are talking about a single machine. Let's look at the figures again. After the split we will have five servers of 13Mb and another five servers of 13Mb. A total of 130Mb memory required. But, hey, we have 230Mb of memory. We've got 100Mb memory freed up. So we can run about eight more servers using the same memory size. We have almost doubled the number of servers without changing machine's hardware (13Mb*18=234Mb). Moreover this new setup allows us to fine tune the two code sets, since in reality the smaller in size code base might have a higher hit rate, so we can benefit even more. Let's assume that based on the usage statistics we know that the first code set deployed in 70% of requests and the other 30% are used by the second set. Now we assume that the first code set requires only 6Mbytes of RAM over the basic mod_perl server size, and the second set needs 14Mbytes (we try to make the comparisons against the same original setup where there were ten processes of 23Mbytes in size each). So now the first mod_perl server running the first code set will have all its processes of 9Mbytes in size (3Mb+6Mb), and the second of 17Mb (3Mb+14Mb). Given that we have a 70:30 hits relation and that we have 230Mbytes of available memory, we have to solve this equation: 0.7*X * 9 + 0.3*X * 17 = 230 where X is the total number of the processes that can be run using the 230Mbytes of available memory, and 0.7 and 0.3 reflect the 70:30 hits relation, 9 and 17 are the respective sizes of the two servers and with their code sets in use. When we solve this simple equation, we get that X equals 20 and therefore, we need 14 processes for the first code set and 6 processes for the second. If we compare this findings with the initial setup we have doubled the number of the servers from 10 to 20. The hits rate optimized solution allowed us to run two more servers in total and gave us five more servers (14 versus 9) for the most wanted code base, relative to the simple 50:50 split as in the first example. Of course if you can identify more than two distinct sets of code and your hits rate statistics may require more complicated decisions. You ought to make even more splits and run three and more mod_perl servers. Remember that having too many running processes doesn't necessarily means a better performance because of all of them will fight over CPU time slices. The more processes are running the less CPU time each gets the slower the overall performance will be. Therefore after hitting a certain load you might want to start spreading servers over different machine. __ Stas Bekman | JAm_pH--Just Another mod_perl Hacker http://stason.org/ | mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] | http://perl.orghttp://stason.org/TULARC/ http://singlesheaven.com| http://perlmonth.com http://sourcegarden.org --
shrinking memory (was Re: Modperl/Apache deficiencies... Memory usage.)
Since you are talking about garbage collection (memory shrinking) you might want to re-read the thread I've started back in Aug, 99: http://forum.swarthmore.edu/epigone/modperl/zarwhegerd It includes the real show case of memory shrinking (at least on Linux). Consider this code: --- use GTop; my $gtop = GTop-new; print "Content-type: text/plain\n\n"; print "before :", $gtop-proc_mem($$)-size,"\n"; { push my @x, "A" x 100; print "in scope :", $gtop-proc_mem($$)-size,"\n"; } print "out of scope :", $gtop-proc_mem($$)-size,"\n"; --- prints on a freshly started server: before :6111232 in scope :8118272 out of scope :7114752 and on a second invocation: before :7118848 in scope :8122368 out of scope :7118848 What do you say? 1003520 bytes are returned to OS when @x goes out of scope. Note that this doesn't happen if you use a global @x instead. But hey why did I need mod_perl for the test, stupid me :) Running the above code as a Perl script from the command line gives: before :1527808 in scope :3543040 out of scope :2539520 The machine is running linux x86 (RH6.1) kernel 2.2.12-20smp, perl5.005_03 __ Stas Bekman | JAm_pH--Just Another mod_perl Hacker http://stason.org/ | mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] | http://perl.orghttp://stason.org/TULARC/ http://singlesheaven.com| http://perlmonth.com http://sourcegarden.org --
mod_perl installed but not active
I compiled succesfully mod_perl together with other modules (see below) into apache 1.3.12. Unfortunately I cannot activate it. The module isn't visible in the error log at startup and the insertion of module directives yields to errors. I can't understand why a make test into the mod_perl source runs without any error. Thanks for any hints, Werner httpsd -l Compiled-in modules: http_core.c mod_env.c mod_log_config.c mod_mime.c mod_negotiation.c mod_status.c mod_include.c mod_autoindex.c mod_dir.c mod_cgi.c mod_asis.c mod_imap.c mod_actions.c mod_userdir.c mod_alias.c mod_access.c mod_auth.c mod_setenvif.c apache_ssl.c mod_perl.c mod_frontpage.c mod_php3.c suexec: enabled; valid wrapper /usr/local/apache/bin/suexec
Re: Modperl/Apache deficiencies... Memory usage.
On Tue, 18 Apr 2000 [EMAIL PROTECTED] wrote: On Mon, Apr 17, 2000 at 01:33:08PM -0600, Jason Terry wrote: This is the first i have seen "delete" referenced. What does it do? How is it used? Thank you -Jason It's the stack cleaner... but it only works for scalars, and maybe arrays, but its better for arrays and hashes to do the following at the bottom of each code block in registry scripts. (True good note) @somearray = (); %somehash =(); delete $somescalar; (and don't forget untie :- ) Basically it will clean up *most* of the memory taken up by these variables. Ouch - maybe you should read a perl book before trying to re-implement mod_perl more efficiently ;-) From "perldoc -f delete": =item delete EXPR Deletes the specified key(s) and their associated values from a hash. ... -- Matt/ Fastnet Software Ltd. High Performance Web Specialists Providing mod_perl, XML, Sybase and Oracle solutions Email for training and consultancy availability. http://sergeant.org http://xml.sergeant.org
Re: mod_perl installed but not active
On Tue, 18 Apr 2000, Werner Reisberger wrote: I compiled succesfully mod_perl together with other modules (see below) into apache 1.3.12. Unfortunately I cannot activate it. The module isn't visible in the error log at startup and the insertion of module directives yields to errors. I can't understand why a make test into the mod_perl source runs without any error. http://perl.apache.org/guide/install.html#How_can_I_tell_whether_mod_perl_ You probably didn't configure it to run: http://perl.apache.org/guide/config.html Thanks for any hints, Werner httpsd -l Compiled-in modules: http_core.c mod_env.c mod_log_config.c mod_mime.c mod_negotiation.c mod_status.c mod_include.c mod_autoindex.c mod_dir.c mod_cgi.c mod_asis.c mod_imap.c mod_actions.c mod_userdir.c mod_alias.c mod_access.c mod_auth.c mod_setenvif.c apache_ssl.c mod_perl.c mod_frontpage.c mod_php3.c suexec: enabled; valid wrapper /usr/local/apache/bin/suexec __ Stas Bekman | JAm_pH--Just Another mod_perl Hacker http://stason.org/ | mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] | http://perl.orghttp://stason.org/TULARC/ http://singlesheaven.com| http://perlmonth.com http://sourcegarden.org --
Setting AuthUserFile dynamically ...
Hi, I asked yesterday about using httpd.conf to set the AuthUserFile dynamically. Maybe I'm trying to paddle up a creek in a barb wire canoe. Is it possible to do something like below? i.e. use a variable in the AuthUserFile line? Or how can I do this? Directory /systems/v2.0 PerlSendHeader On SetHandler perl-script PerlHandler Apache::Registry Options +ExecCGI RewriteRule ^/bin/([^/]+)/(.*) /systems/v2.0/$2 [E=STATUS:$1] [PT] This line AuthUserFile /systems/$1/passwd/users and this line AuthName "$1" AuthType Basic require valid-user Limit GET POST PUT DELETE require valid-user /Limit ErrorDocument 401 /systems/v2.0/error/401.html ErrorDocument 403 /systems/v2.0/error/403.html ErrorDocument 404 /systems/v2.0/error/404.html ErrorDocument 500 /systems/v2.0/error/500.html /Directory regards Scott Scott Alexander tietoverkkosuunnittelija [EMAIL PROTECTED] gsm: +358 (0)40 7505640
Where to get Apache::Session
Hi, Can somebody please tell me from where to download Apache::Session module. Thanks a lot Murali Differentiated Software Solutions Pvt. Ltd., 176, Gr. Floor, 6th Main 2nd Block RT Nagar Bangalore - 560 032 India Ph: 91 80 3431470 email : diffs+AEA-vsnl.com http://www.diffs-india.com
Error compiling mod_perl on linux
Hi all, I tried to compile mod_perl with Apache on RedHat 6.1 and perl 5.005_03, it gave me thousands of unresolved references when compiling httpd.c. I then went thru the FAQs on the Web, and it told me that my perl maybe corrupted. Then I go to grab the latest perl 5.6.0 source, compiled and installed it successfully. This time when I build Apache again, it dies even earlier. Below shows all the steps I used to built it: # cd apache_1.3.12 # ./configure --prefix=/www # cd ../php-3.0.16 # ./configure --with-apache=../apache_1.3.12 \ ...other_stuffs... # make make install # cd ../mod_perl-1.21 # perl Makefile.PL EVERYTHING=1 USE_APACI=1 # make make install # cd ../apache_1.3.12 # ./configure --prefix=/www \ --enable-module=most \ --activate-module=src/modules/php3/libphp3.a \ --activate-module=src/modules/perl/libperl.a # make (died here) [...snipped] === src/modules/perl cc -O2 -g -DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE _SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/lib/perl5/5.6.0/i686-linux/CORE -DMOD _PERL_VERSION=\"1.21\" -DMOD_PERL_STRING_VERSION=\"mod_perl/1.21\" -I../.. -I/usr/lib/perl5/5.6.0/i686-linux/CORE -I../../os/unix -I../../include -D LINUX=2 -DMOD_PERL -DUSE_PERL_SSI -DDEBUGGING -fno-strict-aliasing -I/usr/lo cal/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DUSE_HSREGEX -DUSE_E XPAT -I../../lib/expat-lite -DNO_DL_NEEDED `../../apaci` -c mod_perl.c mod_perl.c: In function `perl_handler': mod_perl.c:783: `PL_siggv' undeclared (first use in this function) mod_perl.c:783: (Each undeclared identifier is reported only once mod_perl.c:783: for each function it appears in.) make[4]: *** [mod_perl.o] Error 1 make[3]: *** [all] Error 1 make[2]: *** [subdirs] Error 1 make[2]: Leaving directory `/depot/apache_1.3.12/src' make[1]: *** [build-std] Error 2 make[1]: Leaving directory `/depot/apache_1.3.12' make: *** [build] Error 2 Attached are the outputs of perl -V of both versions. Any help would be greatly appreciated. Kenneth Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration: Platform: osname=linux, osvers=2.2.5-22smp, archname=i386-linux uname='linux porky.devel.redhat.com 2.2.5-22smp #1 smp wed jun 2 09:11:51 edt 1999 i686 unknown ' hint=recommended, useposix=true, d_sigaction=define usethreads=undef useperlio=undef d_sfio=undef Compiler: cc='cc', optimize='-O2', gccversion=egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include' ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include' stdchar='char', d_stdstdio=undef, usevfork=false intsize=4, longsize=4, ptrsize=4, doublesize=8 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 alignbytes=4, usemymalloc=n, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -ldl -lm -lc -lposix -lcrypt libc=, so=so, useshrplib=false, libperl=libperl.a Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic' cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib' Characteristics of this binary (from libperl): Built under linux Compiled at Aug 30 1999 23:09:51 @INC: /usr/lib/perl5/5.00503/i386-linux /usr/lib/perl5/5.00503 /usr/lib/perl5/site_perl/5.005/i386-linux /usr/lib/perl5/site_perl/5.005 . Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration: Platform: osname=linux, osvers=2.2.12-20, archname=i686-linux uname='linux tongtong.alfacomtech.com 2.2.12-20 #1 mon sep 27 10:40:35 edt 1999 i686 unknown ' config_args='-der' hint=previous, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=undef d_sfio=undef uselargefiles=define use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef Compiler: cc='cc', optimize='-O2 -g', gccversion=egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) cppflags='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64' ccflags ='-DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64' stdchar='char', d_stdstdio=define, usevfork=false intsize=4, longsize=4, ptrsize=4, doublesize=8 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, usemymalloc=n, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt libc=/lib/libc-2.1.2.so, so=so, useshrplib=false, libperl=libperl.a Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic' cccdlflags='-fpic', lddlflags='-shared
Re: [RFC] Do Not Run Everything on One mod_perl Server
It used to be one process for everything, or at least one application for everything. Then mod_perl comes in and people have started using a tiered system (plain server + mod_perl server). Now you're talking about individual application servers. Someday, maybe the script will load the server instead of the other way around! use mod_perl (8080, 3); # (port, #processes) Sorry, feeling philosophical this morning. Thanks for the report. ELB -- Eric L. Brine | Chicken: The egg's way of making more eggs. [EMAIL PROTECTED] | Do you always hit the nail on the thumb? ICQ# 4629314 | An optimist thinks thorn bushes have roses.
Problem with CGI::Carp under mod_perl
I'm having problems using "CGI::Carp qw(fatalsToBrowser);" in modperl scripts. Below are three short scripts and their output under Apache/CGI and Apache/modperl. All three of them produce (more or less) useful output under Apache/CGI, but only the last one does under Apache/modperl. The first one calls die() itself. Under Apache/CGI the die() message appears in the web browser (albeit preceded by a spurious Content-Type line), but under Apache/modperl the message goes to the error.log and a bizarre message appears in the web browser consisting of some output from the script, followed by a "200 OK" HTTP header, followed by a message suggesting that all was not OK after all (all the same as if CGI::Carp was not being used). The second one has a syntax error. Under Apache/CGI a message about a compilation error appears in the web browser (but not the detail of the syntax error itself, which disappears completely - not even going to error.log!); under Apache/modperl an "Internal Server Error" message appears in the web browser (again just like CGI::Carp was not being used) and (curiously) the detail of the syntax error does now at least appear in error.log! The third one attempts a division by zero and correctly says so in the web browser under both Apache/CGI and Apache/modperl. Can anybody explain what's going on here??? The first script is closest to the problem I've really got. I'm using DBI/DBD::mysql and I want SQL syntax errors (which I keep making) to appear in the web browser instead of having to keep opening the error.log. Running under Apache/CGI I get useful messages like: Software error: DBD::mysql::st execute failed: You have an error in your SQL syntax near 'BINARY USER_NAME LIKE 'mk-%' LIMIT 10' at line 1 at d:/inetpub/cgi-bin/mysql.pl line 300. but under Apache/modperl I just get useless garbage like the error_die.pl below produces. I'm running Perl 5.005_03 / Apache 1.3.6 / mod_perl 1.22 on NT 4. error_die.pl use CGI::Carp qw(fatalsToBrowser); $| = 1; print "Content-Type: text/html\n\n"; print "I'm about to die() ...\n"; die "I'm dead.\n"; Apache/CGI: I'm about to die() ... Content-type: text/html Software error: I'm dead. For help, please send mail to the webmaster ([EMAIL PROTECTED]), giving this error message and the time and date of the error. Apache/modperl: I'm about to die() ... HTTP/1.1 200 OK Date: Tue, 18 Apr 2000 11:09:35 GMT Server: Apache/1.3.6 (Win32) mod_perl/1.22 Connection: close Content-Type: text/html OK The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, [EMAIL PROTECTED] and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. error_syntax.pl --- use CGI::Carp qw(fatalsToBrowser); $| = 1; print "Content-Type: text/html\n\n"; print "Syntax error at the end of this line ...\n" print "blah blah blah.\n"; Apache/CGI: Software error: Execution of d:/inetpub/cgi-bin/error_syntax.pl aborted due to compilation errors. For help, please send mail to the webmaster ([EMAIL PROTECTED]), giving this error message and the time and date of the error. Apache/modperl: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, [EMAIL PROTECTED] and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. error_divide.pl --- use CGI::Carp qw(fatalsToBrowser); $| = 1; print "Content-Type: text/html\n\n"; print "I'm about to divide by zero ...\n"; my $x = 1 / 0; Apache/CGI: Software error: Illegal division by zero at d:/inetpub/cgi-bin/error_divide.pl line 5. For help, please send mail to the webmaster ([EMAIL PROTECTED]), giving this error message and the time and date of the error. Apache/modperl: Software error: Illegal division by zero at d:/inetpub/cgi-bin/error_divide.pl line 5. For help, please send mail to the webmaster ([EMAIL PROTECTED]), giving this error message and the time and date of the error.
Re: Problem with CGI::Carp under mod_perl
On Tue, 18 Apr 2000, Steve Hay wrote: I'm having problems using "CGI::Carp qw(fatalsToBrowser);" in modperl scripts. Then don't use CGI::Carp. The whole qw(fatalsToBrowser) thing is broken, IMHO, anyway. See http://modperl.sergeant.org/guide/exceptions.html for a better way to handle exceptions. -- Matt/ Fastnet Software Ltd. High Performance Web Specialists Providing mod_perl, XML, Sybase and Oracle solutions Email for training and consultancy availability. http://sergeant.org http://xml.sergeant.org
[admin] no HTML posts please
"When thou enter a city, abide by its customs" -- Talmud Please, please refrain *posting* in *HTML*! If you want to get help, take another second to *think* what are you doing *before* you send the email... Say 'Yes' to the plain text, 'No' to HTML! Thank you! P.S. I don't know answers for all your questions. I don't claim that I answer on many questions at all. But be sure that I won't answer to the posts in HTML, because my mail client doesn't support HTML (don't tell me that I should upgrade my mail client, my client is just fine). I encourage others to do the same. People should learn to exercise the netiquette if they want to get help for free. P.S.S.: You might want to read some informative resources, e.g.: http://www.primenet.com/~vez/neti.html http://www.gweep.bc.ca/~edmonds/usenet/ml-etiquette.html ftp://rtfm.mit.edu/pub/usenet/news.answers/usenet/primer/part1 And for some laughs: http://www.templetons.com/brad/emily.html __ Stas Bekman | JAm_pH--Just Another mod_perl Hacker http://stason.org/ | mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] | http://perl.orghttp://stason.org/TULARC/ http://singlesheaven.com| http://perlmonth.com http://sourcegarden.org --
Problem with CGI::Carp under mod_perl
Sorry! Here it is again in text/plain this time... (My mail client doesn't ask whether I want to send in text or HTML, hence the slip. Maybe *I* should get a new one!) --- I'm having problems using "CGI::Carp qw(fatalsToBrowser);" in modperl scripts. Below are three short scripts and their output under Apache/CGI and Apache/modperl. All three of them produce (more or less) useful output under Apache/CGI, but only the last one does under Apache/modperl. The first one calls die() itself. Under Apache/CGI the die() message appears in the web browser (albeit preceded by a spurious Content-Type line), but under Apache/modperl the message goes to the error.log and a bizarre message appears in the web browser consisting of some output from the script, followed by a "200 OK" HTTP header, followed by a message suggesting that all was not OK after all (all the same as if CGI::Carp was not being used). The second one has a syntax error. Under Apache/CGI a message about a compilation error appears in the web browser (but not the detail of the syntax error itself, which disappears completely - not even going to error.log!); under Apache/modperl an "Internal Server Error" message appears in the web browser (again just like CGI::Carp was not being used) and (curiously) the detail of the syntax error does now at least appear in error.log! The third one attempts a division by zero and correctly says so in the web browser under both Apache/CGI and Apache/modperl. Can anybody explain what's going on here??? The first script is closest to the problem I've really got. I'm using DBI/DBD::mysql and I want SQL syntax errors (which I keep making) to appear in the web browser instead of having to keep opening the error.log. Running under Apache/CGI I get useful messages like: Software error: DBD::mysql::st execute failed: You have an error in your SQL syntax near 'BINARY USER_NAME LIKE 'mk-%' LIMIT 10' at line 1 at d:/inetpub/cgi-bin/mysql.pl line 300. but under Apache/modperl I just get useless garbage like the error_die.pl below produces. I'm running Perl 5.005_03 / Apache 1.3.6 / mod_perl 1.22 on NT 4. error_die.pl use CGI::Carp qw(fatalsToBrowser); $| = 1; print "Content-Type: text/html\n\n"; print "I'm about to die() ...\n"; die "I'm dead.\n"; Apache/CGI: I'm about to die() ... Content-type: text/html Software error: I'm dead. For help, please send mail to the webmaster ([EMAIL PROTECTED]), giving this error message and the time and date of the error. Apache/modperl: I'm about to die() ... HTTP/1.1 200 OK Date: Tue, 18 Apr 2000 11:09:35 GMT Server: Apache/1.3.6 (Win32) mod_perl/1.22 Connection: close Content-Type: text/html OK The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, [EMAIL PROTECTED] and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. error_syntax.pl --- use CGI::Carp qw(fatalsToBrowser); $| = 1; print "Content-Type: text/html\n\n"; print "Syntax error at the end of this line ...\n" print "blah blah blah.\n"; Apache/CGI: Software error: Execution of d:/inetpub/cgi-bin/error_syntax.pl aborted due to compilation errors. For help, please send mail to the webmaster ([EMAIL PROTECTED]), giving this error message and the time and date of the error. Apache/modperl: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, [EMAIL PROTECTED] and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. error_divide.pl --- use CGI::Carp qw(fatalsToBrowser); $| = 1; print "Content-Type: text/html\n\n"; print "I'm about to divide by zero ...\n"; my $x = 1 / 0; Apache/CGI: Software error: Illegal division by zero at d:/inetpub/cgi-bin/error_divide.pl line 5. For help, please send mail to the webmaster ([EMAIL PROTECTED]), giving this error message and the time and date of the error. Apache/modperl: Software error: Illegal division by zero at d:/inetpub/cgi-bin/error_divide.pl line 5. For help, please send mail to the webmaster ([EMAIL PROTECTED]), giving this error message and the time and date of the error.
Re: mod_perl installed but not active
"WR" == Werner Reisberger [EMAIL PROTECTED] writes: WR I compiled succesfully mod_perl together with other modules (see below) WR into apache 1.3.12. Unfortunately I cannot activate it. The module isn't WR visible in the error log at startup and the insertion of module directives WR yields to errors. WR I can't understand why a make test into the mod_perl source runs without WR any error. If you share with us the exact text of the error messages, and how you configured mod_perl, we might be able to offer help.
Re: [OT] mysql-modules for Win32 platform
On Mon, 17 Apr 2000, Erich Markert wrote: I've been trying to get the msql-mysql-modules compiled and installed on my Win98 machine for a couple weeks without much luck. [snip] My questions are: 1. Is there a binary version of *just* DBI,Msql-Mysql-modules for Win32? 2. If not, is there a PPM of the above for Activestate's perl 5.6 for Win32 (I did a search for DBD::mysql but it failed)? Hi, A DBI ppm package for ActiveState's 5.6.0 build is available at http://www.activestate.com/ppmpackages/5.6/. For DBD-mysql, Jochen Wiedmann has a 5.6.0 ppm package which you can install via ppm install ftp://ftp.de.uu.net/pub/CPAN/authors/id/JWIED/DBD-mysql-1.2212.x86.ppd best regards, randy kobes
Re: Setting AuthUserFile dynamically ...
Scott Alexander ([EMAIL PROTECTED]) said something to this effect: Hi, I asked yesterday about using httpd.conf to set the AuthUserFile dynamically. Maybe I'm trying to paddle up a creek in a barb wire canoe. Is it possible to do something like below? i.e. use a variable in the AuthUserFile line? Or how can I do this? Hi Scott, Have you tried setting the PerlAuthenHandler via $r-push_handlers, in a PerlInitHandler? The code, and the assignment, will be in code, although it could be in a Perl section within your conf file. darren -- Tell a man that there are 400 Billion stars and he'll believe you Tell him that a bench has wet paint and he has to touch it
[ANNOUNCE] Apache::XPath::NotXSLT
I've made a version of my Non-XSLT xpath template processor available as an Apache module. It uses some standard apache caching tricks to speed up delivery, and I can actually get a whopping 9 requests per second out of it (try that with an XSLT processor!). I'm making my site use it now. http://xml.sergeant.org/ -- Matt/ Fastnet Software Ltd. High Performance Web Specialists Providing mod_perl, XML, Sybase and Oracle solutions Email for training and consultancy availability. http://sergeant.org http://xml.sergeant.org
XML::Parser causing SEGFAULT in Apache under mod_perl
I'm currently using XML::Parser (2.28) under Apache (1.3.11) and mod_perl (1.21) and have noticed a fairly large number of segfaults in the Apache error_log. I noticed a discussion about this problem on the list about a week ago, but the only solution posted was as a Debian package (which I can't use). No mention of the actual problem/solution was mentioned. Is anyone else experiencing this problem, and does anyone have a solution I can apply to the XML::Parser 2.28 source? Any info would be greatly appreciated. Thanks. -Michael-
Re: Error compiling mod_perl on linux
On Tue, 18 Apr 2000, Kenneth Lee wrote: Hi all, I tried to compile mod_perl with Apache on RedHat 6.1 and perl 5.005_03, it gave me thousands of unresolved references when compiling httpd.c. I then went thru the FAQs on the Web, and it told me that my perl maybe corrupted. Then I go to grab the latest perl 5.6.0 source, compiled and installed it successfully. This time when I build Apache again, it dies even earlier. Kenneth, You need to get mod_perl-1.22: http://www.perl.com/CPAN-local/modules/by-module/Apache/mod_perl-1.22.tar.gz -jwb
Re: Segfault on DBI-Connect
Drew Degentesh wrote: Below is a backtrace of my segfault received on DBI-Connect (sorry but my perl and apache binaries are stripped)... you can see that mysql_close is being called with a null argument, rather than mysql_real_connect as indicated in some of the other backtraces reported. -+- Starting program: /usr/local/apache/bin/httpd -X Program received signal SIGSEGV, Segmentation fault. mysql_close (mysql=0x0) at libmysql.c:1555 1555 end_server(mysql); #0 mysql_close (mysql=0x0) at libmysql.c:1555 #1 0x403bf254 in __DTOR_END__ () from /usr/lib/perl5/site_perl/5.005/i386-linux/auto/DBD/mysql/mysql.so #2 0x403ac0dd in mysql_dr_connect () from /usr/lib/perl5/site_perl/5.005/i386-linux/auto/DBD/mysql/mysql.so This looks like you are calling mysql_real_connect, something fails and so mysql_close is called with a NULL argument. Can you deduce somehow what goes wrong? We might check the MySQL sources then? Thanks, Jochen
Re: Problem with CGI::Carp under mod_perl
On Tue, 18 Apr 2000, Steve Hay wrote: I'm having problems using "CGI::Carp qw(fatalsToBrowser);" in modperl scripts. [...] The first one calls die() itself. Under Apache/CGI the die() message appears in the web browser (albeit preceded by a spurious Content-Type line), but under Apache/modperl the message goes to the error.log and a bizarre message appears in the web browser consisting of some output from the script, followed by a "200 OK" HTTP header, followed by a message suggesting that all was not OK after all (all the same as if CGI::Carp was not being used). Sounds like a difference in the way CGI scripts and mod_perl buffer. I fyou really want CGI::Carp to work, you need to make sure you don't send any output before it gets called. Maybe you have PerlSendHeader on? The second one has a syntax error. Under Apache/CGI a message about a compilation error appears in the web browser (but not the detail of the syntax error itself, which disappears completely - not even going to error.log!); under Apache/modperl an "Internal Server Error" message appears in the web browser (again just like CGI::Carp was not being used) and (curiously) the detail of the syntax error does now at least appear in error.log! CGI::Carp can't catch compile errors. - Perrin
WindowsNT Explorer like look and feel??
Does anyone know of an easy way to get a WindowsNT explorer (expanding directory/folder) lokk and feel using modperl?
Re: WindowsNT Explorer like look and feel??
On Tue, 18 Apr 2000, Tim Fox wrote: Does anyone know of an easy way to get a WindowsNT explorer (expanding directory/folder) lokk and feel using modperl? You forgot to add a smiley. And you're _way_ past April 1st. -- Matt/ Fastnet Software Ltd. High Performance Web Specialists Providing mod_perl, XML, Sybase and Oracle solutions Email for training and consultancy availability. http://sergeant.org http://xml.sergeant.org
RE: WindowsNT Explorer like look and feel??
On Tue, 18 Apr 2000, Tim Fox wrote: Does anyone know of an easy way to get a WindowsNT explorer (expanding directory/folder) lokk and feel using modperl? You forgot to add a smiley. And you're _way_ past April 1st. Or is this yet another example of a general lack of understanding of the Client/Server architecture and the request/response nature of a web application? John --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.134 / Virus Database: 63 - Release Date: 20/03/00
Re: WindowsNT Explorer like look and feel??
On Tue, 18 Apr 2000, Matt Sergeant wrote: On Tue, 18 Apr 2000, Tim Fox wrote: Does anyone know of an easy way to get a WindowsNT explorer (expanding directory/folder) lokk and feel using modperl? You forgot to add a smiley. And you're _way_ past April 1st. Perhaps some country's Postal Service has gotten into the business of email delivery? (actually, Canada's has ...) Try the HTML-EP-Explorer package at $CPAN/authors/id/JWIED/. best regards, randy kobes
RE: WindowsNT Explorer like look and feel??
On Tue, 18 Apr 2000, John Reid wrote: On Tue, 18 Apr 2000, Tim Fox wrote: Does anyone know of an easy way to get a WindowsNT explorer (expanding directory/folder) lokk and feel using modperl? You forgot to add a smiley. And you're _way_ past April 1st. Or is this yet another example of a general lack of understanding of the Client/Server architecture and the request/response nature of a web application? I really hope that someone who doesn't understand that isn't in the position to be installing/using mod_perl. But then again nothing really shocks me these days. -- Matt/ Fastnet Software Ltd. High Performance Web Specialists Providing mod_perl, XML, Sybase and Oracle solutions Email for training and consultancy availability. http://sergeant.org http://xml.sergeant.org
Re: WindowsNT Explorer like look and feel??
On Tue, 18 Apr 2000, Mark Wagner wrote: On Tue, 18 Apr 2000, Tim Fox wrote: Does anyone know of an easy way to get a WindowsNT explorer (expanding directory/folder) lokk and feel using modperl? You forgot to add a smiley. And you're _way_ past April 1st. Or is this yet another example of a general lack of understanding of the Client/Server architecture and the request/response nature of a web application? What I took it to mean was: is there a mod_perl interface to Apache's dirmagic (or whatever the auto dir listing creator thing is) so that one may create a new way of displaying dirs without reimplementing dirmagic completely? The fact is pure and simple: This is a html question. -- Matt/ Fastnet Software Ltd. High Performance Web Specialists Providing mod_perl, XML, Sybase and Oracle solutions Email for training and consultancy availability. http://sergeant.org http://xml.sergeant.org
Passing POST Data to a SubRequest
Is there a way to pass data into a SubRequest using the post method? I'm sure there's something I'm missing ... here's what I have so far: Insidethe content handler of my priamary request I can create a subrequest using my $subr = $r-lookup_uri($uri); I realize that I can set various headers like the Content-Type and Content-Length using $subr-header_in('Content-Length' = 1234); Then I can run the content handler of the subrequest using $subr-run; Inside the content handler for the subrequest I want to be able to read the data using: $r-read($buff, $r-header_in('Content-Length')); Any ideas on how I would set-up the buffer that $r-read() reads from? Regards, Chris D'Annunzio
Re: WindowsNT Explorer like look and feel??
I do not have a perl or mod_perl example. However in my "Javascript Manual of Style", there is an example of a WindowsNT Explorer like navigator. The code is too lengthy to post and I don't have it loaded myself. However, if you go to... http://www.he.net/~marcj/mos/ch5a.htm you can see an example of the program to see if that's the type of thing you're looking for. It's really a pretty neat procedure and makes navigating something like a manual very easy. You can also contact the author of the book (and code), Marc Johnson at... http://www.he.net/~marcj/index.html Perhaps a mod_perl procedure to build the javascript page which displays the navigational information? In any event, I hope this helps. Regards, Ron
Re: WindowsNT Explorer like look and feel??
Tim Fox wrote: Does anyone know of an easy way to get a WindowsNT explorer (expanding directory/folder) lokk and feel using modperl? Maybe you should be looking at mod_dav rather than mod_perl; The URL is here: http://www.webdav.org/mod_dav/
Core dump
Title: Core dump Got a different code dump. I'm not sure if this one is mod_perl related though... My httpd.conf and startup.pl are the same as my 4/9/2000 post. Anyone know what perform_idle_server_maintenance might be doing that could cause a segfault? -Robert $ gdb /usr/local/apache/bin/httpd core GNU gdb 4.17.0.13 with Linux support Copyright 1998 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type show copying to see the conditions. There is absolutely no warranty for GDB. Type show warranty for details. This GDB was configured as i386-redhat-linux... Core was generated by `/usr/local/apache/bin/httpd -d /home/vusr_demo01/projects/apache'. Program terminated with signal 11, Segmentation fault. Reading symbols from /lib/libm.so.6...done. Reading symbols from /lib/libcrypt.so.1...done. Reading symbols from /lib/libdl.so.2...done. Reading symbols from /lib/libc.so.6...done. Reading symbols from /lib/ld-linux.so.2...done. Reading symbols from /lib/libnss_files.so.2...done. Reading symbols from /usr/local/apache/libexec/libperl.so...done. Reading symbols from /lib/libnsl.so.1...done. Reading symbols from /lib/libdb.so.3...done. Reading symbols from /usr/lib/libgdbm.so.2...done. Reading symbols from /usr/lib/perl5/5.00503/i386-linux/auto/POSIX/POSIX.so...done. Reading symbols from /usr/lib/perl5/site_perl/5.005/i386-linux/auto/Storable/Storable.so...done. Reading symbols from /usr/lib/perl5/5.00503/i386-linux/auto/IO/IO.so...done. Reading symbols from /usr/lib/perl5/5.00503/i386-linux/auto/Fcntl/Fcntl.so...done. Reading symbols from /usr/lib/perl5/site_perl/5.005/i386-linux/auto/Digest/MD5/MD5.so...done. Reading symbols from /usr/lib/perl5/site_perl/5.005/i386-linux/auto/DBI/DBI.so...done. Reading symbols from /usr/lib/perl5/site_perl/5.005/i386-linux/auto/XML/Parser/Expat/Expat.so... done. Reading symbols from /usr/lib/perl5/site_perl/5.005/i386-linux/auto/HTML/Parser/Parser.so... done. Reading symbols from /usr/lib/perl5/site_perl/5.005/i386-linux/auto/Date/Calc/Calc.so...done. Reading symbols from /usr/lib/perl5/site_perl/5.005/i386-linux/pdflib.so...done. Reading symbols from /usr/lib/libpdf2.01.so...done. Reading symbols from /usr/lib/libtiff.so.3...done. Reading symbols from /usr/lib/libjpeg.so.62...done. Reading symbols from /usr/lib/libz.so.1...done. Reading symbols from /usr/lib/perl5/site_perl/5.005/i386-linux/auto/DBD/Oracle/Oracle.so...done. Reading symbols from /usr/lib/libclntsh.so.1.0...done. #0 0x4089fbb6 in kputac () (gdb) where #0 0x4089fbb6 in kputac () #1 0x408bf8b6 in OCISessionEnd () #2 0x4046b388 in ora_db_disconnect () #3 0x40468399 in XS_DBD__Oracle__db_DESTROY () #4 0x402c3082 in XS_DBI_dispatch () #5 0x401e82b6 in Perl_pp_entersub () #6 0x401ba5dc in perl_call_sv () #7 0x401ec69a in Perl_sv_clear () #8 0x401ec9dc in Perl_sv_free () #9 0x401e8d9d in do_clean_objs () #10 0x401e8d1c in visit () #11 0x401e8e18 in Perl_sv_clean_objs () #12 0x401b8e2a in perl_destruct () #13 0x4019e161 in perl_shutdown () #14 0x4019f534 in perl_child_exit () #15 0x4019f2d9 in perl_child_exit_cleanup () #16 0x809996e in run_cleanups () #17 0x809818d in ap_clear_pool () #18 0x8098201 in ap_destroy_pool () #19 0x80a4bb3 in clean_child_exit () #20 0x80a6857 in just_die () #21 signal handler called #22 0x4005c800 in _ufc_foobar () #23 0x80a7b27 in child_main () #24 0x80a812c in make_child () #25 0x80a84a6 in perform_idle_server_maintenance () #26 0x80a89d5 in standalone_main () #27 0x80a8fa3 in main () #28 0x4007f493 in __libc_start_main (main=0x80a8c4c main, argc=3, argv=0xb544, init=0x806a42c _init, fini=0x81396ac _fini, rtld_fini=0x4000a840 _dl_fini, stack_end=0xb53c) at ../sysdeps/generic/libc-start.c:78
Re: [OT] LWP: Regression testing a mod_perl server
Cool, thanks for the quick response, Stas. I don't seem to have LWP::Parallel. Looks like I need to upgrade to the newest version of LWP. But yes, I did notice that ab gives much more accurate results. I was using Time::HiRes to simply measure the time it takes from request to response, and it gave widely varying results. Which was why I wanted to do a loop so I could divide the total time taken by the number of iterations. I'm glad to hear you're already working on it. I'll definitely help out with your regression suite, because I haven't gotten too far on mine (I just started working on it today). Thanks for the LWP list ref.. I'll post the question there. -Adi Stas Bekman wrote: First I work on a similar suite as well. I didn't want to announce it yet, before I get some things working. But since you've mentioned it here, here we go... Hope to get the first version out of the door in a few days. Regarding LWP, I've used a similar to ab script as described at http://perl.apache.org/guide/performance.html and I've found the results are very different if you the same test with ab and LWP::Parallel, so I'd not recommend using it if you want to figure out the *real* numbers. Do you see a different behavior with your tests? So based on these findings I use ab and parse the output to make a different report than ab does. I didn't find the answer for your original answer in the LWP::UserAgent manpage, but probably the right address is the libwww list: The latest version of this library is likely to be available from CPAN as well as: http://www.linpro.no/lwp/ The best place to discuss this code is on the [EMAIL PROTECTED] mailing list. __ Stas Bekman | JAm_pH--Just Another mod_perl Hacker http://stason.org/ | mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] | http://perl.orghttp://stason.org/TULARC/ http://singlesheaven.com| http://perlmonth.com http://sourcegarden.org --
ANNOUNCE: Apache-TicketAccess 0.10
Apache-TicketAccess-0.10.tar.gz has entered CPAN as file: $CPAN/authors/id/M/MS/MSCHOUT/Apache-TicketAccess-0.10.tar.gz size: 9388 bytes md5: 42a00ba96205ead6a0d03cb25903bae6 This is the inital version of Apache::TicketAccess. This version does not yet subclass Apache::AuthCookie, but the next version probably will use AuthCookie to handle all cookie related logic. This was uploaded last week, so it should be on most of the CPAN mirrors by now :). Mike
Re: Modperl/Apache deficiencies... Memory usage.
On Tue, Apr 18, 2000 at 02:07:24AM -0400, Jeff Stuart wrote: I understand that. :) And that was something that I had to learn myself. :) It's a BAD thing when suddenly your httpd process takes up 100 MB. :) It's just that it sounded like Shane was saying that his httpds were starting OUT at 4 to 6 MB. That sounded a little unusual to me but then again, I've pared down my httpd config so that I don't have things in that I don't need. I'm just curious as to what he has in there. -- Jeff Stuart [EMAIL PROTECTED] Well, the machine I took the estimates off of was a dev machine. Which means that the key is *capability* not so much ability to serve up lots of requests. Your right, if I were to re-hash my configs to be something other than a dev box I could serve a lot more hits and have a smaller apache mem usage. The other box I was talking about is pared down, but I obviously can't restart a clients machine at will just to do a calculation for the mod_perl list :-). In direct response to your question though :)... I have about 20 modules compiled in. Not to mention the modules that I'm loading..., but here's the compiled in list for your curiousity: Compiled-in modules: http_core.c mod_env.c mod_log_config.c mod_mime.c mod_negotiation.c mod_status.c mod_include.c mod_autoindex.c mod_dir.c mod_cgi.c mod_asis.c mod_imap.c mod_actions.c mod_userdir.c mod_alias.c mod_access.c mod_auth.c mod_setenvif.c mod_jserv.c Thanks, Shane.
Re: Modperl/Apache deficiencies... Memory usage.
On Tue, Apr 18, 2000 at 01:24:16PM +0800, Gunther Birznieks wrote: If you aren't careful with your programming, an apache HTTPD can always grow pretty quickly because Perl never releases the RAM it allocates previously. While it does that reference count garbage collection, that is internal to the RAM that was allocated. Let's say you need to sort a record set returned from a DBI call in an unusual perl-like way. If you do this "in memory", you need an array to hold the entire recordset in memory at once. If you do this, though, you will allocate the RAM for that one request that sorted the array and then the HTTPD will remain that size forever. Keeping the higher RAM allocation is good for performance if you have the RAM of course. So this is one of those design tradeoffs. And Perl was not really written to be a persistent language, so again, the tradeoff of operational speed seems to make sense versus persistent memory usage. Later, Gunther Gunther, Curiosity leads me to the following question...: So what your talking about is lets say a variable becomes 40k large, or bigger. Since we're talking about a pretty big operation we could even be talking in terms of several 100k, but anyway: That variable would retain it's size throughout the persistence of the perl interpretor, correct? And that memory would be specific to that variable? Hm.. okay, that's where I was getting messed up. The variables value is lost after the block end, but it's size is never realloc'd down to something more appropriate? That's an interesting problem in and of itself. So if you were to do something like this: $i=20; $bigvar="something thats 40k long"; somememoryhog($bigvar); sub somememoryhog { my $var=shift; somemoryhog($var) if($i--=0); } It would call some memory hog 20 times, each time it would copy the value of $bigvar onto the next level down of the recursive stack of somememoryhog. The total memory usage would be 20*40k=800k, and it would never re allocate that variable down to a reasonable size? That's the behaviour I thought that would happen, but I was thinking the value would be retained through the stack (clearly my error). (Okay, so sue me it would call somememory hog more than 20 times, I'm just trying to clear up something :-) Thanks, Shane.
Re: Modperl/Apache deficiencies... Memory usage.
Actually, it is a bit more complicated. I was wrong in my assumptions. To be more blunt, I was wrong period. :) I had been testing some stuff using global variables and experienced this behavior of non-releasing RAM. Since then a few people privately showed me otherwise and Stas' posted a thread pointing to a discussion on this issue from a past-mod_perl list discussion. It is still the case that one needs to be careful with how variables grow in mod_perl, but it is not entirely the case that the RAM is always not freed. Here is the URL that Stas posted which makes some of these persistent server memory issues more clear (perhaps even for a growing Java server). http://forum.swarthmore.edu/epigone/modperl/zarwhegerd Later, Gunther At 11:19 AM 4/19/00 +, [EMAIL PROTECTED] wrote: On Tue, Apr 18, 2000 at 01:24:16PM +0800, Gunther Birznieks wrote: If you aren't careful with your programming, an apache HTTPD can always grow pretty quickly because Perl never releases the RAM it allocates previously. While it does that reference count garbage collection, that is internal to the RAM that was allocated. Let's say you need to sort a record set returned from a DBI call in an unusual perl-like way. If you do this "in memory", you need an array to hold the entire recordset in memory at once. If you do this, though, you will allocate the RAM for that one request that sorted the array and then the HTTPD will remain that size forever. Keeping the higher RAM allocation is good for performance if you have the RAM of course. So this is one of those design tradeoffs. And Perl was not really written to be a persistent language, so again, the tradeoff of operational speed seems to make sense versus persistent memory usage. Later, Gunther Gunther, Curiosity leads me to the following question...: So what your talking about is lets say a variable becomes 40k large, or bigger. Since we're talking about a pretty big operation we could even be talking in terms of several 100k, but anyway: That variable would retain it's size throughout the persistence of the perl interpretor, correct? And that memory would be specific to that variable? Hm.. okay, that's where I was getting messed up. The variables value is lost after the block end, but it's size is never realloc'd down to something more appropriate? That's an interesting problem in and of itself. So if you were to do something like this: $i=20; $bigvar="something thats 40k long"; somememoryhog($bigvar); sub somememoryhog { my $var=shift; somemoryhog($var) if($i--=0); } It would call some memory hog 20 times, each time it would copy the value of $bigvar onto the next level down of the recursive stack of somememoryhog. The total memory usage would be 20*40k=800k, and it would never re allocate that variable down to a reasonable size? That's the behaviour I thought that would happen, but I was thinking the value would be retained through the stack (clearly my error). (Okay, so sue me it would call somememory hog more than 20 times, I'm just trying to clear up something :-) Thanks, Shane. __ Gunther Birznieks ([EMAIL PROTECTED]) Extropia - The Web Technology Company http://www.extropia.com/
Perl Sections and Virtual Host
Hello modperlers, I'm currently banging my head on the walls trying to use Perl sections, in the httpd.conf file, to configure virtual hosts. The idea is to redirect lots of 'secondary' domains to URLs on our 'main' website. Let's say the main website is www.main.org, and secondary domain are sec.ondary.com and third.dom.com. With a regular Virtual host config, no sweat (well, it seems so; maybe an Apache expert will tell me I forgot something big and important :-) NameVirtualHost 192.168.1.2:80 VirtualHost 192.168.1.2:80 ServerName sec.ondary.com RedirectPermanent / http://www.main.org/second/index.phtml /VirtualHost VirtualHost 192.168.1.2:80 ServerName third.dom.com RedirectPermanent / http://www.main.org/third/index.phtml /VirtualHost Since we have several secondary domains, and lots of URLs to remap in different ways depending on the secondary domain, I thought going through a Perl section would be cute. So, dumbly, I wrote this to replace the VirtualHost sections above (the NameVirtualHost does not change) : Perl my $realname = 'http://www.main.org'; my %vnames = ( 'sec.ondary.com' = 'second', 'third.dom.com' = 'third' ); foreach (keys %vnames) { $VirtualHost{'192.168.1.2:80'} = { ServerName = $_, RedirectPermanent = ( ['/', "$realname/$vname{$_}/index.phtml"] ) } } /Perl No way. No errors during the server startup, but also no redirection whatsoever. Where am I wrong, or what did I forget ? I'm using Embedded Perl version 5.00503 for Apache/1.3.9 (Unix) mod_perl/1.21 mod_ssl/2.4.9 OpenSSL/0.9.4 Tia, -- Pierre-Yves BONNETAIN CTO http://www.rouge-blanc.com -- Fastest wines in Europe
cvs commit: modperl-2.0/src/modules/perl modperl_callback.c
dougm 00/04/18 15:58:10 Added: src/modules/perl modperl_callback.c Log: implement handler parsing get started on basic callbacks Revision ChangesPath 1.1 modperl-2.0/src/modules/perl/modperl_callback.c Index: modperl_callback.c === #include "mod_perl.h" static void require_module(pTHX_ const char *pv) { SV* sv; dSP; PUSHSTACKi(PERLSI_REQUIRE); PUTBACK; sv = sv_newmortal(); sv_setpv(sv, "require "); sv_catpv(sv, pv); eval_sv(sv, G_DISCARD); SPAGAIN; POPSTACK; } modperl_handler_t *modperl_handler_new(ap_pool_t *p, void *h, int type) { modperl_handler_t *handler = (modperl_handler_t *)ap_pcalloc(p, sizeof(*handler)); switch (type) { case MP_HANDLER_TYPE_SV: handler-cv = SvREFCNT_inc((SV*)h); MpHandlerPARSED_On(handler); break; case MP_HANDLER_TYPE_CHAR: handler-name = (char *)h; MP_TRACE_h(MP_FUNC, "new handler %s\n", handler-name); break; }; ap_register_cleanup(p, (void*)handler, modperl_handler_cleanup, ap_null_cleanup); return handler; } ap_status_t modperl_handler_cleanup(void *data) { modperl_handler_t *handler = (modperl_handler_t *)data; dTHXa(handler-perl); modperl_handler_unparse(aTHX_ handler); return APR_SUCCESS; } void modperl_handler_cache_cv(pTHX_ modperl_handler_t *handler, CV *cv) { if (1) { /* XXX: figure out how to invalidate cache * e.g. if subroutine is redefined */ handler-cv = SvREFCNT_inc((SV*)cv); /* handler-cvgen = MP_sub_generation; */; } else { handler-cv = newSVpvf("%s::%s", HvNAME(GvSTASH(CvGV(cv))), GvNAME(CvGV(cv))); } MP_TRACE_h(MP_FUNC, "caching %s::%s\n", HvNAME(GvSTASH(CvGV(cv))), GvNAME(CvGV(cv))); } int modperl_handler_lookup(pTHX_ modperl_handler_t *handler, char *class, char *name) { CV *cv; GV *gv; HV *stash = gv_stashpv(class, FALSE); if (!stash) { MP_TRACE_h(MP_FUNC, "class %s not defined, attempting to load\n", class); require_module(aTHX_ class); if (SvTRUE(ERRSV)) { MP_TRACE_h(MP_FUNC, "failed to load %s class\n", class); return 0; } else { MP_TRACE_h(MP_FUNC, "loaded %s class\n", class); if (!(stash = gv_stashpv(class, FALSE))) { MP_TRACE_h(MP_FUNC, "%s package still does not exist\n", class); return 0; } } } if ((gv = gv_fetchmethod(stash, name)) (cv = GvCV(gv))) { if (CvFLAGS(cv) CVf_METHOD) { /* sub foo : method {}; */ MpHandlerMETHOD_On(handler); handler-obj = newSVpv(class, 0); handler-cv = newSVpv(name, 0); } else { modperl_handler_cache_cv(aTHX_ handler, cv); } MpHandlerPARSED_On(handler); MP_TRACE_h(MP_FUNC, "found `%s' in class `%s' as a %s\n", name, HvNAME(stash), MpHandlerMETHOD(handler) ? "method" : "function"); return 1; } MP_TRACE_h(MP_FUNC, "`%s' not found in class `%s'\n", name, HvNAME(stash)); return 0; } void modperl_handler_unparse(pTHX_ modperl_handler_t *handler) { int was_parsed = handler-args || handler-cv || handler-obj; if (!MpHandlerPARSED(handler)) { if (was_parsed) { MP_TRACE_h(MP_FUNC, "handler %s was parsed, but not flagged\n", handler-name); } else { MP_TRACE_h(MP_FUNC, "handler %s was never parsed\n", handler-name); return; } } MpHandlerFLAGS(handler) = 0; handler-cvgen = 0; if (handler-args) { av_clear(handler-args); SvREFCNT_dec((SV*)handler-args); handler-args = Nullav; } if (handler-cv) { SvREFCNT_dec(handler-cv); handler-cv = Nullsv; } if (handler-obj) { SvREFCNT_dec(handler-obj); handler-obj = Nullsv; } MP_TRACE_h(MP_FUNC, "%s unparsed\n", handler-name); } int modperl_handler_parse(pTHX_ modperl_handler_t *handler) { char *name = handler-name; char *tmp; CV *cv; if (strnEQ(name, "sub ", 4)) { handler-cv = eval_pv(name, FALSE); MP_TRACE_h(MP_FUNC, "handler is anonymous\n"); if (!SvTRUE(handler-cv) || SvTRUE(ERRSV)) {
cvs commit: modperl-2.0/src/modules/perl mod_perl.c modperl_callback.h modperl_config.c modperl_config.h modperl_log.c modperl_types.h
dougm 00/04/18 15:59:15 Modified:lib/ModPerl Code.pm src/modules/perl mod_perl.c modperl_callback.h modperl_config.c modperl_config.h modperl_log.c modperl_types.h Log: integrate with modperl_callback.c beef up tracing support Revision ChangesPath 1.12 +43 -9 modperl-2.0/lib/ModPerl/Code.pm Index: Code.pm === RCS file: /home/cvs/modperl-2.0/lib/ModPerl/Code.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- Code.pm 2000/04/17 21:11:06 1.11 +++ Code.pm 2000/04/18 22:59:13 1.12 @@ -49,12 +49,14 @@ {type = 'char', name = 'arg'}], cfg = {get = 'MP_dSCFG(parms-server)', name = 'scfg'}, +scope = 'RSRC_CONF', }, PerDir = { args = [{type = 'cmd_parms', name = 'parms'}, {type = 'modperl_dir_config_t', name = 'dcfg'}, {type = 'char', name = 'arg'}], cfg = {get = '', name = 'dcfg'}, +scope = 'OR_ALL', }, ); @@ -70,7 +72,7 @@ Srv = [qw(NONE PERL_TAINT_CHECK PERL_WARN FRESH_RESTART)], Dir = [qw(NONE INCPUSH SENDHDR SENTHDR ENV CLEANUP RCLEANUP)], Interp = [qw(NONE IN_USE PUTBACK CLONED)], -Handler = [qw(NONE METHOD)], +Handler = [qw(NONE PARSED METHOD OBJECT ANON)], ); sub new { @@ -141,17 +143,27 @@ for my $h (@$handlers) { my $name = canon_func('cmd', $h, 'handlers'); +my $cmd_name = canon_define('cmd', $h, 'entry'); my $protostr = canon_proto($prototype, $name); my $ix = $self-{handler_index}-{$class}-[$i++]; my $av = "$prototype-{cfg}-{name}-handlers[$ix]"; print $h_fh "$protostr;\n"; + +print $h_fh EOF; + +#define $cmd_name \\ +{"Perl${h}Handler", $name, NULL, \\ + $prototype-{scope}, ITERATE, "Subroutine name"} + +EOF print $c_fh EOF; $protostr { $prototype-{cfg}-{get}; -return modperl_cmd_push_handlers($av, arg, parms-pool); +MP_TRACE_d(MP_FUNC, "push \@%s, %s\n", parms-cmd-name, arg); +return modperl_cmd_push_handlers(($av), arg, parms-pool); } EOF } @@ -185,22 +197,34 @@ } } -my @trace = qw(d s h g c i m); +my %trace = ( +#'a' = 'all', +'d' = 'directive processing', +'s' = 'perl sections', +'h' = 'handlers', +'m' = 'memory allocations', +'i' = 'interpreter pool management', +'g' = 'Perl runtime interaction', +); sub generate_trace { my($self, $h_fh) = @_; my $i = 1; +my @trace = sort keys %trace; my $opts = join '', @trace; +my $tl = "MP_debug_level"; print $h_fh EOF; -extern U32 MP_debug_level; +extern U32 $tl; #define MP_TRACE_OPTS "$opts" #ifdef MP_TRACE -#define MP_TRACE_a if (MP_debug_level) modperl_trace -#define MP_TRACE_a_do(exp) if (MP_debug_level) exp +#define MP_TRACE_a if ($tl) modperl_trace +#define MP_TRACE_a_do(exp) if ($tl) { \\ +exp; \\ +} #else #define MP_TRACE_a if (0) modperl_trace #define MP_TRACE_a_do(exp) @@ -208,21 +232,31 @@ EOF +my @dumper; for my $type (@trace) { my $define = "#define MP_TRACE_$type"; my $define_do = join '_', $define, 'do'; print $h_fh EOF; #ifdef MP_TRACE -$define if (MP_debug_level $i) modperl_trace -$define_do(exp) if (MP_debug_level $i) exp +$define if ($tl $i) modperl_trace +$define_do(exp) if ($tl $i) { \\ +exp; \\ +} #else $define if (0) modperl_trace $define_do(exp) #endif EOF +push @dumper, + qq{fprintf(stderr, " $type %s ($trace{$type})\\n", ($tl $i) ? "On " : "Off");}; $i += $i; } + +print $h_fh join ' \\'."\n", + '#define MP_TRACE_dump_flags()', + qq{fprintf(stderr, "mod_perl trace flags dump:\\n");}, + @dumper; } sub ins_underscore { @@ -277,7 +311,7 @@ generate_trace = {h = 'modperl_trace.h'}, ); -my @c_src_names = qw(interp log config gtop); +my @c_src_names = qw(interp log config callback gtop); my @g_c_names = map { "modperl_$_" } qw(hooks directives xsinit); my @c_names = ('mod_perl', (map "modperl_$_", @c_src_names), @g_c_names); sub c_files { [map { "$_.c" } @c_names] } 1.9 +1 -0 modperl-2.0/src/modules/perl/mod_perl.c Index: mod_perl.c === RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- mod_perl.c