cvs commit: modperl-2.0/xs/tables/current/ModPerl FunctionTable.pm
stas2003/01/16 18:26:32 Modified:.Changes xs/Apache/Response Apache__Response.h xs/tables/current/ModPerl FunctionTable.pm Log: fix segfault in send_http_header when it's called before the response phase Revision ChangesPath 1.102 +3 -0 modperl-2.0/Changes Index: Changes === RCS file: /home/cvs/modperl-2.0/Changes,v retrieving revision 1.101 retrieving revision 1.102 diff -u -r1.101 -r1.102 --- Changes 16 Jan 2003 02:38:09 - 1.101 +++ Changes 17 Jan 2003 02:26:31 - 1.102 @@ -10,6 +10,9 @@ =item 1.99_09-dev +fix segfault in send_http_header when it's called before the response +phase [Stas] + input stream filtering support was added + tests (plus renaming filter tests so we can know from the test name what kind of filter is tested) [Stas] 1.8 +11 -2 modperl-2.0/xs/Apache/Response/Apache__Response.h Index: Apache__Response.h === RCS file: /home/cvs/modperl-2.0/xs/Apache/Response/Apache__Response.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- Apache__Response.h19 May 2002 23:01:12 - 1.7 +++ Apache__Response.h17 Jan 2003 02:26:31 - 1.8 @@ -15,7 +15,8 @@ /* XXX: should only be part of Apache::compat */ static MP_INLINE void -mpxs_Apache__RequestRec_send_http_header(request_rec *r, const char *type) +mpxs_Apache__RequestRec_send_http_header(pTHX_ request_rec *r, + const char *type) { MP_dRCFG; @@ -23,7 +24,15 @@ ap_set_content_type(r, apr_pstrdup(r-pool, type)); } -rcfg-wbucket-header_parse = 0; /* turn off PerlOptions +ParseHeaders */ +if (rcfg-wbucket) { +/* turn off PerlOptions +ParseHeaders */ +rcfg-wbucket-header_parse = 0; +} +else { +/* the response is not initialized yet */ +Perl_croak(aTHX_ send_http_header() can't be called before + the response phase); +} } static MP_INLINE void 1.95 +4 -0 modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm Index: FunctionTable.pm === RCS file: /home/cvs/modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm,v retrieving revision 1.94 retrieving revision 1.95 diff -u -r1.94 -r1.95 --- FunctionTable.pm 15 Jan 2003 06:07:10 - 1.94 +++ FunctionTable.pm 17 Jan 2003 02:26:32 - 1.95 @@ -5370,6 +5370,10 @@ 'name' = 'mpxs_Apache__RequestRec_send_http_header', 'args' = [ { +'type' = 'PerlInterpreter *', +'name' = 'my_perl' + }, + { 'type' = 'request_rec *', 'name' = 'r' },
cvs commit: modperl-2.0/xs/tables/current/ModPerl FunctionTable.pm
stas2003/01/16 19:08:31 Modified:src/modules/perl modperl_filter.c modperl_filter.h .Changes xs modperl_xs_util.h xs/Apache/RequestIO Apache__RequestIO.h xs/tables/current/ModPerl FunctionTable.pm Log: prevent segfault in $r-print / $filter-print (in output filter) and related functions when they are called before the response phase Revision ChangesPath 1.44 +11 -4 modperl-2.0/src/modules/perl/modperl_filter.c Index: modperl_filter.c === RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_filter.c,v retrieving revision 1.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- modperl_filter.c 15 Jan 2003 06:07:10 - 1.43 +++ modperl_filter.c 17 Jan 2003 03:08:31 - 1.44 @@ -55,13 +55,18 @@ return rv; } -MP_INLINE apr_status_t modperl_wbucket_write(modperl_wbucket_t *wb, +MP_INLINE apr_status_t modperl_wbucket_write(pTHX_ modperl_wbucket_t *wb, const char *buf, apr_size_t *wlen) { apr_size_t len = *wlen; *wlen = 0; +if (!wb) { +/* the response is not initialized yet */ +Perl_croak(aTHX_ can't be called before the response phase); +} + if ((len + wb-outcnt) sizeof(wb-outbuf)) { apr_status_t rv; if ((rv = modperl_wbucket_flush(wb)) != APR_SUCCESS) { @@ -505,7 +510,8 @@ return filter-rc; } -MP_INLINE apr_status_t modperl_input_filter_write(modperl_filter_t *filter, +MP_INLINE apr_status_t modperl_input_filter_write(pTHX_ + modperl_filter_t *filter, const char *buf, apr_size_t *len) { @@ -519,11 +525,12 @@ return APR_SUCCESS; } -MP_INLINE apr_status_t modperl_output_filter_write(modperl_filter_t *filter, +MP_INLINE apr_status_t modperl_output_filter_write(pTHX_ + modperl_filter_t *filter, const char *buf, apr_size_t *len) { -return modperl_wbucket_write(filter-wbucket, buf, len); +return modperl_wbucket_write(aTHX_ filter-wbucket, buf, len); } apr_status_t modperl_output_filter_handler(ap_filter_t *f, 1.17 +6 -3 modperl-2.0/src/modules/perl/modperl_filter.h Index: modperl_filter.h === RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_filter.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- modperl_filter.h 15 Jan 2003 06:07:10 - 1.16 +++ modperl_filter.h 17 Jan 2003 03:08:31 - 1.17 @@ -16,7 +16,8 @@ MP_INLINE apr_status_t modperl_wbucket_flush(modperl_wbucket_t *b); -MP_INLINE apr_status_t modperl_wbucket_write(modperl_wbucket_t *b, +MP_INLINE apr_status_t modperl_wbucket_write(pTHX_ + modperl_wbucket_t *b, const char *buf, apr_size_t *wlen); @@ -50,7 +51,8 @@ SV *buffer, apr_size_t wanted); -MP_INLINE apr_status_t modperl_output_filter_write(modperl_filter_t *filter, +MP_INLINE apr_status_t modperl_output_filter_write(pTHX_ + modperl_filter_t *filter, const char *buf, apr_size_t *len); @@ -75,7 +77,8 @@ SV *buffer, apr_size_t wanted); -MP_INLINE apr_status_t modperl_input_filter_write(modperl_filter_t *filter, +MP_INLINE apr_status_t modperl_input_filter_write(pTHX_ + modperl_filter_t *filter, const char *buf, apr_size_t *len); 1.103 +5 -2 modperl-2.0/Changes Index: Changes === RCS file: /home/cvs/modperl-2.0/Changes,v retrieving revision 1.102 retrieving revision 1.103 diff -u -r1.102 -r1.103 --- Changes 17 Jan 2003 02:26:31 - 1.102 +++ Changes 17 Jan 2003 03:08:31 - 1.103 @@ -10,8 +10,11 @@ =item 1.99_09-dev -fix
Determining when a cached item is out of date
I'm moving into the XML space and one of the things I see is that XML processing is very expensive, so AxKit, PageKit, et al make extensive use of caching. I'm keeping all of my data in a MySQL DB with about 40 tables. I'm pretty clear about how to turn that MySQL data into XML and turn the XML into HTML, WML, or what have you. But I haven't been able to wrap my skull around knowing when the data in Mysql is fresher than what is in the cache without doing a major portion of the work needed to generate that web page to begin with. Do AxKit and PageKit pay such close attention to caching because XML processing is so deadly slow that one doesn't have a hope of reasonable response times on a fast but lightly loaded server otherwise? Or is it because even a fast server would quickly be on its knees under anything more than a light load? With a MVC type architecture, would it make sense to have the Model objects maintain the XML related to the content I want to serve as static files so that a simple stat of the appropriate XML file tells me if my cached HTML document is out of date? One more thing. Perrin Harkins' eToys case study casually mentions a a means of removing files from the mod_proxy cache directory so that mod_proxy had to go back to the application servers to get an up to date copy. I haven't seen anything in the mod_proxy docs that says this is possible. Does something like that exist outside of eToys? I don't know, maybe my Prussian Perfection gene has taken over again and wants a bigger win than I need to get ... -- Christopher L. Everett Chief Technology Officer The Medical Banner Exchange Physicians Employment on the Internet
PerlSections grief with VirtualHosts
I'm pulling my hair out. I have an extremely complicated Perl section that I'm trying to load in Apache, and I'm having one hell of a time debugging everything. To make a long story short, I'm defining multiple virtualhosts that each are configured to run AxKit. I have my Perl section defined in a separate file, and Include it into my main httpd.conf. I have some debugging code that dumps the PerlSections data to STDOUT when the server starts up. When Apache starts, it dies silently with a core dump (after outputting the Data::Dumper representation of my PerlSections). If I copy/paste the outputted Perl code and re-munge it into Apache's configuration syntax and include this file, the server starts without a problem. Therefore, I know there isn't a problem with the modules I'm loading in the virtualhosts, but I can't seem to track the problem down because I can't get any debugging information. Here's the strace log for httpd -X (actually, just the last few lines, since it's 7262 lines long). Any idea what might be wrong? open(/etc/group, O_RDONLY)= 4 fcntl64(4, F_GETFD) = 0 fcntl64(4, F_SETFD, FD_CLOEXEC) = 0 fstat64(4, {st_mode=S_IFREG|0644, st_size=940, ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4002d000 read(4, root:x:0:root\nbin:x:1:root,bin,d..., 4096) = 940 close(4)= 0 munmap(0x4002d000, 4096)= 0 read(3, s point forward you must specifi..., 4096) = 4096 read(3, ly text or HTML documents, \text..., 4096) = 4096 read(3, .ahtml\n#\n# EBCDICConvertByType ..., 4096) = 4096 read(3, u to place a short description a..., 4096) = 4096 read(3, ere. You probably want to change..., 4096) = 4096 read(3, /1\\.0\ force-response-1.0\n\n/IfM..., 4096) = 4096 getuid32() = 0 geteuid32() = 0 getgid32() = 0 getegid32() = 0 time([1042723461]) = 1042723461 rt_sigprocmask(SIG_BLOCK, NULL, [RT_0], 8) = 0 stat64(/usr/lib/perl5/site_perl/5.6.0/i386-linux, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 stat64(/usr/lib/perl5/site_perl/5.6.0, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 open(/dev/null, O_RDONLY) = 4 fcntl64(4, F_SETFD, FD_CLOEXEC) = 0 fstat64(4, {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 3), ...}) = 0 rt_sigaction(SIGCHLD, NULL, {SIG_DFL}, 8) = 0 --- SIGSEGV (Segmentation fault) --- +++ killed by SIGSEGV +++ -- Michael A Nachbaur [EMAIL PROTECTED] http://nachbaur.com/pgpkey.asc `That young girl is one of the least benightedly unintelligent organic life forms it has been my profound lack of pleasure not to be able to avoid meeting.' -- Marvin's first ever compliment about anybody.
Re: rfc: new filtering APIs
Finally, other than add/remove filters APIs which we have talked about, what other APIs do you want for filters? is there an interface to filter_init? see the discussion on http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9673 or CHANGES file for a description of why it was added. this API may be crucial to mod_perl developers who want to handle conditional GET requests properly with their filters. --Geoff
OK and headers
Is this the right place to ask? I have a handler that picks up requests in a specific location, and usually returns the Apache constant OK. Some of these requests are images. They display fine in all browsers, but when a user right-clicks and selects SAVE AS they only have an option to save as BMP. This is in IE, Netscape7, Opera. Do I need to send additional headers? Thanks in anticipation lee
Re: Determining when a cached item is out of date
On Thu, Jan 16, 2003 at 06:33:52PM +0100, Honza Pazdziora wrote: On Thu, Jan 16, 2003 at 06:05:30AM -0600, Christopher L. Everett wrote: Do AxKit and PageKit pay such close attention to caching because XML processing is so deadly slow that one doesn't have a hope of reasonable response times on a fast but lightly loaded server otherwise? Or is it because even a fast server would quickly be on its knees under anything more than a light load? It really pays off to do any steps that will increase the throughput. And AxKit is well suited for caching because it has clear layers and interfaces between them. So I see AxKit doing caching not only to get the performance, but also just because it can. You cannot do the caching easily with more dirty approaches. With a MVC type architecture, would it make sense to have the Model objects maintain the XML related to the content I want to serve as static files so that a simple stat of the appropriate XML file tells me if my cached HTML document is out of date? Well, AxKit uses filesystem cache, doesn't it? It really depends on how much precission you need to achieve. If you run a website that lists cinema programs, it's just fine that your public will see the updated pages after five minutes, not immediatelly after they were changed by the data manager. Then you can really go with simply timing out the items in the cache. If you need to do something more real-time, you might prefer the push approach of MVC (because pull involves too much processing anyway, as you have said), and then you have a small problem with MySQL. As it lacks trigger support, you will have to send the push invalidation from you applications. Which might or might not be a problem, it depends on how many of them you have. I have pages that update as often as 15 seconds. I just use mtime() and has_changed() properly in my custom provider Provider.pm's or rely on the File::Provider's checking the stat of the xml files. Mostly users are getting cached files. For xsp's that are no_cache(1), the code that generates the inforation that gets sent throught the taglib does its own caching. Just as if it were a plain mod_perl handler. they use IPC::MM and Cache::Cache (usually filecache) I've fooled w/ having the cache use different databases but finally decided it didn't make much of a difference since the os and disk can be tuned effectively. The standard rules apply: put the cache on its own disk spindle, ie. not on the same physical disk as your sql database etc. Makes a big difference ... you can see w/ vmstat, systat etc. The only trouble is cleaning up the ever growing stale cache. So, I use this simple script in my /etc/daily.local file, or a guy could use cron. Its similar to what's openbsd uses for its cleaning of /tmp,/var/tmp in the /etc/daily script. Ed. # cat /etc/clean_www.conf CLEAN_WWW_DIRS=/u4/www/cache /var/www/temp # cat /usr/local/sbin/clean_www #!/bin/sh - # $Id: clean_www.sh,v 1.2 2003/01/03 00:18:27 entropic Exp $ : ${CLEAN_WWW_CONF:=/etc/clean_www.conf} clean_dir() { dir=$1 echo Removing scratch and junk files from '$dir': if [ -d $dir -a ! -L $dir ]; then cd $dir { find . ! -name . -atime +1 -execdir rm -f -- {} \; find . ! -name . -type d -mtime +1 -execdir rmdir -- {} \; \ /dev/null 21; } fi } if [ -f $CLEAN_WWW_CONF ]; then . $CLEAN_WWW_CONF fi if [ X${CLEAN_WWW_CONF} != X ]; then echo for cfg_dir in $CLEAN_WWW_DIRS; do clean_dir ${cfg_dir}; done fi
Fw: Passing CGI environment to subprograms
- Original Message - From: Erich Oliphant [EMAIL PROTECTED] To: Stas Bekman [EMAIL PROTECTED] Sent: Wednesday, January 15, 2003 9:21 PM Subject: Re: Passing CGI environment to subprograms Duh :) Sorry, I thought I included the rev in my original post, yes I am using 2.0. Hmm, and no hacks or workarounds at this point? That sucks ;) Well I will poke around the code and see if I can help out. Also, are the probs I described with getting the output of spawn_proc_prog() known? As I indicated that approach did set the env vars correctly, but I was not able to read the output handle per the example. Thanks!!! - Original Message - From: Stas Bekman [EMAIL PROTECTED] Cc: Erich Oliphant [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, January 15, 2003 7:59 PM Subject: Re: Passing CGI environment to subprograms Stas Bekman wrote: Erich Oliphant wrote: Thanks for the reply, just getting back from a short vacation... My test programs: first.pl --- #!/export/home/eoliphan/gnu/bin/perl -w use strict; my $key; open(LOG, /tmp/firstdebug.log); foreach $key (keys %ENV) { print LOG $key = $ENV{$key} \n; } `/export/home/eoliphan/gnu/cgi-bin/dump_vars.pl`; close (LOG); --- dump_vars.pl has the same foreach loop and dumps to a different log file. The 'firstdebug.log' has the required CGI vars. The log generated by dump_vars.pl has what appears to be the enviroment of the httpd executable and no CGI vars. It works for me with mod_perl 1.0 and doesn't with 2.0. BTW, the 2.0 issue is known. And should be resolved at some point. Here is a quote from modperl_env.c /* * XXX: what we do here might change: * - make it optional for %ENV to be tied to r-subprocess_env * - make it possible to modify environ * - we could allow modification of environ if mpm isn't threaded * - we could allow modification of environ if variable isn't a CGI *variable (still could cause problems) */ /* * problems we are trying to solve: * - environ is shared between threads * + Perl does not serialize access to environ * + even if it did, CGI variables cannot be shared between threads! * problems we create by trying to solve above problems: * - a forked process will not inherit the current %ENV * - C libraries might rely on environ, e.g. DBD::Oracle */ Meanwhile I'll add a note to the compat.pod, to avoid bug reports. __ Stas BekmanJAm_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
Re: OK and headers
Lee Goddard wrote: Is this the right place to ask? I have a handler that picks up requests in a specific location, and usually returns the Apache constant OK. Some of these requests are images. They display fine in all browsers, but when a user right-clicks and selects SAVE AS they only have an option to save as BMP. This is in IE, Netscape7, Opera. Do I need to send additional headers? maybe Content-Disposition would help. --Geoff
Re: Determining when a cached item is out of date
Christopher L. Everett wrote: But I haven't been able to wrap my skull around knowing when the data in Mysql is fresher than what is in the cache without doing a major portion of the work needed to generate that web page to begin with. There are three ways to handle cache synchronization: 1) Time to Live (TTL). This approach just keeps the data cached for a certain amount of time and ignores possible updates. This is the most popular because it is easy to implement and gives good performance. Cache::Cache and friends work this way. 2) Polling. This involves checking the freshness of the data before serving it from cache. This is only feasible if you have a way to check freshness that is faster than re-generating the data. This is difficult in most situations. 3) Invalidation. This approach involves removing cache entried whenever you update something that would make them out of date. This is only feasible if you have total control over the update mechanism and can calculate all the dependencies quickly. One more thing. Perrin Harkins' eToys case study casually mentions a a means of removing files from the mod_proxy cache directory so that mod_proxy had to go back to the application servers to get an up to date copy. I haven't seen anything in the mod_proxy docs that says this is possible. Does something like that exist outside of eToys? Not in mod_proxy. We added it ourselves. I don't have the code for that anymore, but it's not hard to do if you have a competent C hacker handy. Maybe mod_accel has this feature. - Perrin
Re: OK and headers
At 19:01 16/01/2003, Geoffrey Young wrote: Lee Goddard wrote: Is this the right place to ask? I have a handler that picks up requests in a specific location, and usually returns the Apache constant OK. Some of these requests are images. They display fine in all browsers, but when a user right-clicks and selects SAVE AS they only have an option to save as BMP. This is in IE, Netscape7, Opera. Do I need to send additional headers? maybe Content-Disposition would help. Thanks, Geoff. Turns out it was a logged bug in IE combined with a human client who lied about other browsers. Sigh. lee Lee Goddard, BA(Hons), MSc(Sussex) http://www.LeeGoddard.com/ since 1997. Director: Little Bits Ltd - Perl / Java / XML / HTML Contractors Inc. in England #4006170; VAT #755-0139-42
Bricolage on Online Tonight
Hi All, I'll be appearing on Online Tonight again tonight, at 11 pm EST / 8 pm PST. I'll be discussion Bricolage again with host David Lawrence. You can listen live online here: http://www.cnet.com/broadband/0-7227152.html And you can find an affiliate that carry the broadcast by entering your zip code here: http://www.online-tonight.com/ In related news, I posted an edited version of my last appearance on the show in RealAudio format here: http://bricolage.cc/audio/online_tonight.ram Tune in and enjoy! Regards, David -- David Wheeler AIM: dwTheory [EMAIL PROTECTED] ICQ: 15726394 http://david.wheeler.net/ Yahoo!: dew7e Jabber: [EMAIL PROTECTED]
Re: mod_perl 2.0 and print/send_http_header method SEGFAULT
On Thu, Jan 16, 2003 at 10:27:38AM +1100, Stas Bekman wrote: Cool. Now can you please send the shortest possible example that you still get the SEGFAULT with, so I can reproduce it and fix? Thanks. I finally got a working apache2+mod_perl working in my $HOME dir (I could not find the core files of the RedHat httpd, problems with uid permission i guess) So here are the backtraces. I included two backtraces : - the first one is for the crash with $r-send_http_header() - the second one is for the crash with $r-print() when I remove the send_http_header() statement The config in httpd.conf : # mod_perl LoadModule perl_module modules/mod_perl.so PerlModule Apache2 PerlTransHandler Apache::SegFault # proxy LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_ftp_module modules/mod_proxy_ftp.so LoadModule proxy_http_module modules/mod_proxy_http.so LoadModule proxy_connect_module modules/mod_proxy_connect.so ProxyRequests On Proxy * Order deny,allow Deny from all Allow from localhost /Proxy Then I issue a simple request with : echo -ne GET http://perl.apache.org HTTP/1.0\n\n | nc localhost 8081 -8-- Start Bug Report 8-- 1. Problem Description: BEGIN package Apache::SegFault; use strict; use Apache::compat; use Apache::RequestRec; use Apache::RequestIO; use Apache::RequestUtil; use Apache::Const; use Apache::ServerUtil; use Apache::Response; use Apache::URI; use APR::Table; sub handler { my $r = shift; return Apache::DECLINED unless( $r-proxyreq ); print STDERR Good, this is a proxyreq ...\n; return Apache::DECLINED unless( $r-method eq GET ); print STDERR Good, this is a GET method ...\n; my $content = htmlbodyplop/body/html; my %headers_out; $headers_out{ 'Content-length' } = length( $content ); $headers_out{ 'Content-type' } = 'text/html'; foreach (keys %headers_out) { $r-headers_out-{$_} = $headers_out{$_}; } $r-content_type( $headers_out{ 'Content-type' } ); print STDERR -- send/print --\n; # -- SEGFAULT here $r-send_http_header(); # -- or here, when removing the send_http_header() line above $r-print( $content ); print STDERR -- end --\n; return Apache::OK; } 1; END 2. Used Components and their Configuration: *** using lib/Apache/BuildConfig.pm *** Makefile.PL options: MP_APXS= /home/jauge/httpd/bin/apxs MP_DEBUG = 1 MP_GENERATE_XS = 1 MP_LIBNAME = mod_perl MP_MAINTAINER = 1 MP_TRACE = 1 MP_USE_DSO = 1 MP_USE_STATIC = 1 *** /home/jauge/httpd/bin/httpd -V Server version: Apache/2.0.43 Server built: Jan 16 2003 15:38:17 Server's Module Magic Number: 20020903:0 Architecture: 32-bit Server compiled with -D APACHE_MPM_DIR=server/mpm/prefork -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 -D APR_USE_SYSVSEM_SERIALIZE -D APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D HTTPD_ROOT=/home/jauge/httpd -D SUEXEC_BIN=/home/jauge/httpd/bin/suexec -D DEFAULT_PIDLOG=logs/httpd.pid -D DEFAULT_SCOREBOARD=logs/apache_runtime_status -D DEFAULT_LOCKFILE=logs/accept.lock -D DEFAULT_ERRORLOG=logs/error_log -D AP_TYPES_CONFIG_FILE=conf/mime.types -D SERVER_CONFIG_FILE=conf/httpd.conf *** /usr/bin/perl -V Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration: Platform: osname=linux, osvers=2.4.18-11smp, archname=i386-linux-thread-multi uname='linux daffy.perf.redhat.com 2.4.18-11smp #1 smp thu aug 15 06:41:59 edt 2002 i686 i686 i386 gnulinux ' config_args='-des -Doptimize=-O2 -march=i386 -mcpu=i686 -Dmyhostname=localhost -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-linux -Dvendorprefix=/usr -Dsiteprefix=/usr -Duseshrplib -Dusethreads -Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio -Dinstallusrbinperl -Ubincompat5005 -Uversiononly -Dpager=/usr/bin/less -isr' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemultiplicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm', optimize='-O2 -march=i386 -mcpu=i686', cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -I/usr/include/gdbm' ccversion='', gccversion='3.2 20020822 (Red Hat Linux Rawhide 3.2-5)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
problems with apache modperl
I have apache 1.3.27 and perl 5.8 and i have the mod-perl installed in debian box. but everytime i want to shut down the apache server with the command "apachectl gracefull" i get this error : /usr/sbin/apachectl: line 171: 21571 Segmentation fault $HTTPD -t /dev/null 21/usr/sbin/apachectl graceful: configuration broken, ignoring restart /usr/sbin/apachectl graceful: (run 'apachectl configtest' for details) when i run "apachectl configtest" i get this error: [21581]SES: Embperl Session management enabled (= 1.50)Syntax OK/usr/sbin/apachectl: line 171: 21581 Segmentation fault $HTTPD -t please anybody who can help me with this error... thanks
cgi-script to handler communication
Hi, I have two questions: a. How can I communicate a value from my cgi-script to a mod_perl handler. I know you can pass values from handlers to cgi-scripts using $r-args and environment variables. But, what if I want to pass a value from the cgi-script to a handler? It's obvious that the handler should get called after the cgi-script gets executed. b.Also, I don't know of any handler that gets called after the content has been generated. PerlOutputFilterHandler is not what I want, because, there I have to read and manually 'print' all the output using $filter-print. If PerlOutputFilterHandler is the only option, then, can I modify the output headers in it? thanks -vish
Re: Determining when a cached item is out of date
Perrin Harkins wrote: Christopher L. Everett wrote: But I haven't been able to wrap my skull around knowing when the data in Mysql is fresher than what is in the cache without doing a major portion of the work needed to generate that web page to begin with. There are three ways to handle cache synchronization: 1) Time to Live (TTL). This approach just keeps the data cached for a certain amount of time and ignores possible updates. This is the most popular because it is easy to implement and gives good performance. Cache::Cache and friends work this way. I'm cursed by my installed base. Our users go into our site to make sure their changes are up correctly. I don't think a 15 second TTL would do us any good :) 2) Polling. This involves checking the freshness of the data before serving it from cache. This is only feasible if you have a way to check freshness that is faster than re-generating the data. This is difficult in most situations. 3) Invalidation. This approach involves removing cache entried whenever you update something that would make them out of date. This is only feasible if you have total control over the update mechanism and can calculate all the dependencies quickly. I see where one could combine polling and invalidation, for instance by having empty files representing a page that get touched when the data for them go out of date. But again, there is the issue of mapping changed data onto dependent pages. I guess one way to do that is to track which database rows appear in which pages in the database. Since typically I do several database operations to generate a page, adding one more delete or insert operation whanever a new page is generated won't kill me. Could get nasty in a big hurry if I'm not careful though. Perhaps a cache manager object/class that handles cache mappings invalidation would be handy. Or maybe do that as part the PageKit base Model class. One more thing. Perrin Harkins' eToys case study casually mentions a a means of removing files from the mod_proxy cache directory so that mod_proxy had to go back to the application servers to get an up to date copy. I haven't seen anything in the mod_proxy docs that says this is possible. Does something like that exist outside of eToys? Not in mod_proxy. We added it ourselves. I don't have the code for that anymore, but it's not hard to do if you have a competent C hacker handy. Maybe mod_accel has this feature. Well, I like to think I'm language independent, heh. But reinventing the wheel isn't cheap. I'll root around some more. -- Christopher L. Everett Chief Technology Officer The Medical Banner Exchange Physicians Employment on the Internet
Re: modperl : how resolve conflict funtion name in different package
Ouimet, Pierre wrote: hi! I have that (by exemple ) : package pack1.pm sub get_data { # ... } package pack2.pm sub get_data { # same name, but doing other thing } I don't use export and I have conflict with this 2 package in log file (because it detect same function) In modperl I can't have same function ? That's impossible ! I can't beleive that! Is it possible to allow it ? In apache config or... !? Tanks a lot in advance! :) bye Finder It sounds like you're not actually using the package statement: pack1.pm should have a line at the beginning of the file saying 'package pack1;' and pack2.pm should have a line saying 'package pack2;' I'm only guessing what the problem is here, as you don't state exactly what the error message is. Steve -- Steve Piner Web Applications Developer Marketview Limited http://www.marketview.co.nz
Re: PerlSections grief with VirtualHosts
Michael A Nachbaur wrote: I'm pulling my hair out. I have an extremely complicated Perl section that I'm trying to load in Apache, and I'm having one hell of a time debugging everything. To make a long story short, I'm defining multiple virtualhosts that each are configured to run AxKit. I have my Perl section defined in a separate file, and Include it into my main httpd.conf. I have some debugging code that dumps the PerlSections data to STDOUT when the server starts up. When Apache starts, it dies silently with a core dump (after outputting the Data::Dumper representation of my PerlSections). If I copy/paste the outputted Perl code and re-munge it into Apache's configuration syntax and include this file, the server starts without a problem. Therefore, I know there isn't a problem with the modules I'm loading in the virtualhosts, but I can't seem to track the problem down because I can't get any debugging information. First of all I assume that you are talking about mod_perl 1.0 here. You need to get a core file and send in the backtrace as explained here: http://perl.apache.org/docs/1.0/guide/help.html#How_to_Report_Problems If you can't get it see the tips at: http://perl.apache.org/docs/2.0/devel/debug/c.html#Getting_the_core_File_Dumped __ Stas BekmanJAm_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
Re: cgi-script to handler communication
[Please mention mp2 in the subject/body of the message so we don't have to guess what version you are talking about] a. How can I communicate a value from my cgi-script to a mod_perl handler. I know you can pass values from handlers to cgi-scripts using $r-args and environment variables. But, what if I want to pass a value from the cgi-script to a handler? It's obvious that the handler should get called after the cgi-script gets executed. You don't detail what kind of handler you are talking about. But look at notes/pnotes (search perl.apache.org for examples), which are useful for passing data around. b.Also, I don't know of any handler that gets called after the content has been generated. PerlOutputFilterHandler is not what I want, because, there I have to read and manually 'print' all the output using $filter-print. If PerlOutputFilterHandler is the only option, then, can I modify the output headers in it? Looks like you are a bit confused with 'handlers'. You may want to read the handler chapters at http://perl.apache.org/docs/2.0/user/index.html You can insert several handlers (for each phase) using push_handlers or using the configuration file. Depending on the phase's behavior described here: http://perl.apache.org/docs/2.0/user/handlers/intro.html#Single_Phase_s_Multiple_Handlers_Behavior only the first handler returning OK (or error) or all of the handlers will be run. And yes, you can modify output headers in PerlOutputFilterHandler, if the filter is a connection filter. Here is an example that does that for input headers, but will work the same for the output handlers: http://perl.apache.org/docs/2.0/user/handlers/filters.html#Connection_Input_Filters Though it's probably not as fast as adjusting the headers via the api in the response handlers. However since you aren't telling what you are trying to do I can't give you a better advice. __ Stas BekmanJAm_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
Re: modperl : how resolve conflict funtion name in different package
Ouimet, Pierre wrote: hi! I have that (by exemple ) : package pack1.pm sub get_data { # ... } package pack2.pm sub get_data { # same name, but doing other thing } I don't use export and I have conflict with this 2 package in log file (because it detect same function) In modperl I can't have same function ? That's impossible ! I can't beleive that! Is it possible to allow it ? In apache config or... !? Please RTFM: http://perl.apache.org/docs/1.0/guide/porting.html#Name_collisions_with_Modules_and_libs __ Stas BekmanJAm_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
Re: PerlSections grief with VirtualHosts
I'm sorry everyone, this seems to be a case of RTFM. I refined my search criteria, and found a relevant thread on the mailing list archives that solved the problem. In particular, this message: http://www.mail-archive.com/modperl@apache.org/msg27132.html led me in the right direction. Instead of recompiling, I'm simply not use'ing XML::LibXSLT globally. I apologize for the list noise; it was late at night (or _really_ early in the morning, depending on your perspective)...yeah, that's a good excuse. :) -man Stas Bekman wrote: Michael A Nachbaur wrote: I'm pulling my hair out. I have an extremely complicated Perl section that I'm trying to load in Apache, and I'm having one hell of a time debugging everything. To make a long story short, I'm defining multiple virtualhosts that each are configured to run AxKit. I have my Perl section defined in a separate file, and Include it into my main httpd.conf. I have some debugging code that dumps the PerlSections data to STDOUT when the server starts up. When Apache starts, it dies silently with a core dump (after outputting the Data::Dumper representation of my PerlSections). If I copy/paste the outputted Perl code and re-munge it into Apache's configuration syntax and include this file, the server starts without a problem. Therefore, I know there isn't a problem with the modules I'm loading in the virtualhosts, but I can't seem to track the problem down because I can't get any debugging information. First of all I assume that you are talking about mod_perl 1.0 here. You need to get a core file and send in the backtrace as explained here: http://perl.apache.org/docs/1.0/guide/help.html#How_to_Report_Problems If you can't get it see the tips at: http://perl.apache.org/docs/2.0/devel/debug/c.html#Getting_the_core_File_Dumped __ Stas BekmanJAm_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
Re: Fw: Passing CGI environment to subprograms
Erich Oliphant wrote: - Original Message - From: Erich Oliphant [EMAIL PROTECTED] To: Stas Bekman [EMAIL PROTECTED] Sent: Wednesday, January 15, 2003 9:21 PM Subject: Re: Passing CGI environment to subprograms Duh :) Sorry, I thought I included the rev in my original post, yes I am using 2.0. Hmm, and no hacks or workarounds at this point? That sucks ;) Well I will poke around the code and see if I can help out. I think the suggestion was to enable this feature for non-threaded mpms. But what we are trying to achieve is that any module will run identically on threaded and non-threaded mpms (the same reason why Registry modules don't chdir to the script's dir). Also, are the probs I described with getting the output of spawn_proc_prog() known? As I indicated that approach did set the env vars correctly, but I was not able to read the output handle per the example. It's quite possible that there is a bug. Can you please send a test case to reproduce the problem? Thanks. __ Stas BekmanJAm_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
Re: rfc: new filtering APIs
Geoffrey Young wrote: Finally, other than add/remove filters APIs which we have talked about, what other APIs do you want for filters? is there an interface to filter_init? see the discussion on http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9673 or CHANGES file for a description of why it was added. this API may be crucial to mod_perl developers who want to handle conditional GET requests properly with their filters. First of all you can always do: unless ($filter-ctx) { # filter is called for the first time # and this code won't be run only once $filter-ctx(1); } so if you want to do something once, or e.g. remove yourself you can do it in this block. So it seems to be similar to filter_init. Or am I wrong here? I agree that having a dedicated filter_init seems to be cleaner and probably more efficient. If filter_init is wanted, how should it be set by the Perl code? Using an optional second argument to the filter configuration? PerlOutputFilterHandler MyFilter MyFilter::init Also can you please give me some useful test I can play with? Probably one of the examples from your book will do ;) Thanks Geoff. __ Stas BekmanJAm_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
Re: cgi-script to handler communication [MP2]
Though it's probably not as fast as adjusting the headers via the api in the response handlers. However since you aren't telling what you are trying to do I can't give you a better advice. Here's what I'm trying to do: I am implementing a login/logout mechanism. The user can't access any page till he logs in. That is any attempt to access pages without logging in will be redirected to the login screen. I have successfully implemented this part. The login page is generated by a CGI script. Once the user logs in successfully, I want to set a cookie. That's the reason why I want the login CGI script to pass the result to my handler. The handler, which must be run after the CGI script has been run, will decide to modify the output header (to set cookie) depending upon the result code passed to it by the login screen. I have read all the documentation about handlers etc., and couldn't find a way to do this. I know about notes/pnotes, but aren't they for passing values from one handler to other. How can my CGI script use them? And if it is possible for my CGI script to use them, would that be safe when multiple users are trying to log in? One more question. I redirect the incoming request by calling $r-uri($new_uri) in my PerlTransHandler. How can I make the browser show this new location in its address bar? Let me know if you need to know more about any aspect of my implementation. And, thanks for your help. -vish
Re: cgi-script to handler communication [MP2]
Vishal Verma wrote: Though it's probably not as fast as adjusting the headers via the api in the response handlers. However since you aren't telling what you are trying to do I can't give you a better advice. Here's what I'm trying to do: I am implementing a login/logout mechanism. The user can't access any page till he logs in. That is any attempt to access pages without logging in will be redirected to the login screen. I have successfully implemented this part. The login page is generated by a CGI script. Once the user logs in successfully, I want to set a cookie. That's the reason why I want the login CGI script to pass the result to my handler. The handler, which must be run after the CGI script has been run, will decide to modify the output header (to set cookie) depending upon the result code passed to it by the login screen. I don't understand why don't you do that in your cgi script (btw, is it running under mod_perl/registry or just mod_cgi?). Why do you need yet another handler? I have read all the documentation about handlers etc., and couldn't find a way to do this. I know about notes/pnotes, but aren't they for passing values from one handler to other. How can my CGI script use them? And if it is possible for my CGI script to use them, would that be safe when multiple users are trying to log in? If it's a mod_perl registry script, you have an access to the request object. Either via my $r = shift; at the beginning of your script or via Apache-request (which retrieves the globally stored req object) If it's a script running under the mod_cgi handler, I don't think you can. One more question. I redirect the incoming request by calling $r-uri($new_uri) in my PerlTransHandler. How can I make the browser show this new location in its address bar? in mod_cgi scripts: print Location: $new_location; or use CGI; print CGI-new-redirect($new_location); or talking mod_perl, see for example: http://perl.apache.org/docs/1.0/guide/snippets.html#Sending_Cookies_in_REDIRECT_Response __ Stas BekmanJAm_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
Apache::Session
Hello, I am looking for a PPM version of Apache::Session for Perl (v5.8.0 built for MSWin32-x86-multi-thread) and Apache/2.0.43. Any pointers would be greatly appreciated. Thanks, Carl Holm [EMAIL PROTECTED]
Re: mod_perl 2.0 and print/send_http_header method SEGFAULT
Jérôme Augé wrote: On Thu, Jan 16, 2003 at 10:27:38AM +1100, Stas Bekman wrote: Cool. Now can you please send the shortest possible example that you still get the SEGFAULT with, so I can reproduce it and fix? Thanks. I finally got a working apache2+mod_perl working in my $HOME dir (I could not find the core files of the RedHat httpd, problems with uid permission i guess) So here are the backtraces. I included two backtraces : - the first one is for the crash with $r-send_http_header() - the second one is for the crash with $r-print() when I remove the send_http_header() statement The problem is that you were calling these functions before the response phase (PerlTransHandler in your case), hence triggered the segfaults. I've fixed those in cvs. Now if you call any of these functions too early mod_perl will croak. Please verify with the latest cvs. To solve your particular case, you need to use: $r-set_handlers(PerlResponseHandler = \response); inside the PerlTransHandler handler, and move all the code that generates the response there. __ Stas BekmanJAm_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
RE: Apache::Session
Carl Have you check the active perl site (http://www.activeperl.com) ? It may be available there -Original Message- From: Carl Holm [mailto:[EMAIL PROTECTED]] Sent: Thu 1/16/2003 9:12 PM To: [EMAIL PROTECTED] Cc: Subject: Apache::Session Hello, I am looking for a PPM version of Apache::Session for Perl (v5.8.0 built for MSWin32-x86-multi-thread) and Apache/2.0.43. Any pointers would be greatly appreciated. Thanks, Carl Holm [EMAIL PROTECTED] This message may contain proprietary or confidential company information. Any unauthorized use or disclosure is prohibited.
Re: Apache::Session
On Thu, 16 Jan 2003, Carl Holm wrote: Hello, I am looking for a PPM version of Apache::Session for Perl (v5.8.0 built for MSWin32-x86-multi-thread) and Apache/2.0.43. Any pointers would be greatly appreciated. Thanks, Carl Holm [EMAIL PROTECTED] I just put one up under http://theoryx5.uwinnipeg.ca/ppms/. However, some of the tests fail and/or hang under ActivePerl 8xx ... -- best regards, randy kobes
Re: cgi-script to handler communication [MP2]
Umm, sanity check: You _have_ checked out the many packages and modules that do just this under mod_perl, haven't you? On 16 Jan 2003, Vishal Verma wrote: Though it's probably not as fast as adjusting the headers via the api in the response handlers. However since you aren't telling what you are trying to do I can't give you a better advice. Here's what I'm trying to do: I am implementing a login/logout mechanism. The user can't access any page till he logs in. That is any attempt to access pages without logging in will be redirected to the login screen. I have successfully implemented this part. The login page is generated by a CGI script. Once the user logs in successfully, I want to set a cookie. That's the reason why I want the login CGI script to pass the result to my handler. The handler, which must be run after the CGI script has been run, will decide to modify the output header (to set cookie) depending upon the result code passed to it by the login screen. I have read all the documentation about handlers etc., and couldn't find a way to do this. I know about notes/pnotes, but aren't they for passing values from one handler to other. How can my CGI script use them? And if it is possible for my CGI script to use them, would that be safe when multiple users are trying to log in? One more question. I redirect the incoming request by calling $r-uri($new_uri) in my PerlTransHandler. How can I make the browser show this new location in its address bar? Let me know if you need to know more about any aspect of my implementation. And, thanks for your help. -vish - nick Nick Tonkin {|8^)
Re: Determining when a cached item is out of date
Christopher L. Everett wrote: I see where one could combine polling and invalidation, for instance by having empty files representing a page that get touched when the data for them go out of date. More commonly you would combine TTL with invalidation. You use invalidation for the simple stuff, where people need to make instant updates they can see, and you use TTL to catch everything else. But again, there is the issue of mapping changed data onto dependent pages. Tracking dependencies gets difficult quickly, and that's why almost no one does it. TTL is very efficient, if you can live with data being out of sync for a little while. - Perrin
Re: problems with apache modperl
Hi, there seems to be a problem with Embperl when you do the configtest (the graceful does a configtest first). I have seem something like this on windows, when you install Apache as a service, but no on unix yet. The graceful restart would work, without the configtest before. Which version of Embperl you are running? If it is an 1.3.x version, please make sure you upgrade to 1.3.5 before we continue Gerald -Gerald Richter ecos electronic communication services gmbhInternetconnect * Webserver/-design/-datenbanken * Consulting Post: Tulpenstrasse 5 D-55276 Dienheim b. MainzE-Mail: [EMAIL PROTECTED] Voice: +49 6133 925131WWW: http://www.ecos.de Fax: +49 6133 925152- - Original Message - From: HeRnAn DeL bOcA To: [EMAIL PROTECTED] Sent: Thursday, January 16, 2003 9:19 PM Subject: problems with apache modperl I have apache 1.3.27 and perl 5.8 and i have the mod-perl installed in debian box. but everytime i want to shut down the apache server with the command "apachectl gracefull" i get this error : /usr/sbin/apachectl: line 171: 21571 Segmentation fault $HTTPD -t /dev/null 21/usr/sbin/apachectl graceful: configuration broken, ignoring restart /usr/sbin/apachectl graceful: (run 'apachectl configtest' for details) when i run "apachectl configtest" i get this error: [21581]SES: Embperl Session management enabled (= 1.50)Syntax OK/usr/sbin/apachectl: line 171: 21581 Segmentation fault $HTTPD -t please anybody who can help me with this error... thanks