SubRequest in Filter MP2 [QUESTION]
Hello, I am a newbie to this list, so please forgive me if this is not the place where I should asking this question. I am writing a filter module for MP2 that will parse its input for certain embedded commands. One of these commands should cause the filter to issue a SubRequest to get the output of another file or cgi script on the server. The output of the SubRequest will also be processed, and I will need to have access to the headers it returned, I can then set cookies etc. In MP1 I had big problems when it came to processing the output of a SubRequest because there was no way of capturing the output. In MP2 Progress has been somewhat slower since I am unfamiliar with the documentation. Before porting all my code from MP1 to MP2 I decided to write some test scripts to check that I was able to use the functionality that I require. Here is my test setup Files ~ \.html PerlOutputFilterHandler Apache::testfilter /Files package Apache::testfilter; use strict; use warnings; use Apache::Filter (); use Apache::SubRequest (); use Apache::RequestRec (); use APR::Table (); use Apache::Const -compile = qw(OK); use constant BUFF_LEN = 1024; sub handler { my $f = shift; unless ($f-ctx) { $f-r-headers_out-unset('Content-Length'); $f-ctx(1); my $rr = $f-r-lookup_uri(subrequest.txt); #$rr-run; } #From the filter example on perl.apache.org */ while ($f-read(my $buffer, BUFF_LEN)) { $buffer =~ s/[\r\n]//g; $f-print($buffer); } $f-print(\nEnd of Filter\n); return Apache::OK; } 1; For some reason, the server segfaults when the above code is run (with the $rr-run line present) [Mon Aug 25 16:16:12 2003] [notice] Graceful restart requested, doing restart apache2: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName [Mon Aug 25 16:16:12 2003] [notice] Apache/2.0.47 (Debian GNU/Linux) mod_perl/1.99_09 Perl/v5.8.0 configured -- resuming normal operations Then when I make a request... [Mon Aug 25 16:16:16 2003] [notice] child pid 13250 exit signal Segmentation fault (11) I know I am doing something wrong because I have still not figured out a way to obtain the output from the subrequest. After a few hours of trying different things, I found that a subrequest will work if it is in one of the handler modules eg PerlResponseHandler I would like to thank anyone (in advance) for helping me solve this problem. -- Craig Shelley [EMAIL PROTECTED] A goto in Perl falls into the category of hard things that should be possible, not easy things that should be easy. -- Larry Wall in [EMAIL PROTECTED] -- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html
Re: SubRequest in Filter MP2 [QUESTION]
does anything change if you use $rr = $f-$r-lookup_uri(subrequest.txt, $f-next); No it doesn't seem any different, the server still seg faults. When it does this, it produces no output at all. telnet 127.0.0.1 80 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. GET / HTTP/1.0 Connection closed by foreign host. Thank you for looking into this. -- Craig Shelley [EMAIL PROTECTED] Just don't create a file called -rf. :-) -- Larry Wall in [EMAIL PROTECTED] -- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html
Re: SubRequest in Filter MP2 [QUESTION]
I'll take a look at it. But you didn't supply a complete bug report as explained http://perl.apache.org/bugs/. Please do so. Hi, Here is that bug report related to the earlier postings. -8-- Start Bug Report 8-- 1. Problem Description: [DESCRIBE THE PROBLEM HERE] 2. Used Components and their Configuration: *** using lib/Apache/BuildConfig.pm *** Makefile.PL options: MP_AP_PREFIX = /home/craig/temp/mod_perl-1.99_09/ MP_COMPAT_1X = 1 MP_GENERATE_XS = 1 MP_LIBNAME = mod_perl MP_USE_DSO = 1 MP_USE_STATIC = 1 *** /usr/local/bin/httpd -V Server version: Apache/2.0.47 Server built: Jul 15 2003 14:07:14 Server's Module Magic Number: 20020903:4 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 (IPv4-mapped addresses enabled) -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= -D SUEXEC_BIN=/usr/lib/apache2/suexec2 -D DEFAULT_PIDLOG=/var/run/httpd.pid -D DEFAULT_SCOREBOARD=logs/apache_runtime_status -D DEFAULT_LOCKFILE=/var/run/accept.lock -D DEFAULT_ERRORLOG=logs/error_log -D AP_TYPES_CONFIG_FILE=/etc/apache2/mime.types -D SERVER_CONFIG_FILE=/etc/apache2/apache2.conf *** /usr/bin/perl -V Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration: Platform: osname=linux, osvers=2.4.21-xfs+ti1211, archname=i386-linux-thread-multi uname='linux kosh 2.4.21-xfs+ti1211 #1 sat jul 12 10:35:04 est 2003 i686 gnulinux ' config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=i386-linux -Dprefix=/usr -Dprivlib=/usr/share/perl/5.8.0 -Darchlib=/usr/lib/perl/5.8.0 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.8.0 -Dsitearch=/usr/local/lib/perl/5.8.0 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Uusesfio -Uusenm -Duseshrplib -Dlibperl=libperl.so.5.8.0 -Dd_dosuid -des' 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='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O3', cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing' ccversion='', gccversion='3.3.1 20030722 (Debian prerelease)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 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, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lgdbm -ldb -ldl -lm -lpthread -lc -lcrypt perllibs=-ldl -lm -lpthread -lc -lcrypt libc=/lib/libc-2.3.1.so, so=so, useshrplib=true, libperl=libperl.so.5.8.0 gnulibc_version='2.3.1' 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): Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PERL_IMPLICIT_CONTEXT Built under linux Compiled at Jul 30 2003 10:52:58 %ENV: PERL_LWP_USE_HTTP_10=1 @INC: /etc/perl /usr/local/lib/perl/5.8.0 /usr/local/share/perl/5.8.0 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8.0 /usr/share/perl/5.8.0 /usr/local/lib/site_perl . 3. This is the core dump trace: (if you get a core dump): [CORE TRACE COMES HERE] This report was generated by t/REPORT on Tue Aug 26 17:17:34 2003 GMT. -8-- End Bug Report --8-- __ 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 -- Craig Shelley [EMAIL PROTECTED] -- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html
Re: SubRequest in Filter MP2 [QUESTION]
On Tue, 2003-08-26 at 19:03, Stas Bekman wrote: Thanks, but you have missed the core dump's backtrace. I am sorry but I have never used core files before, so forgive me if I have done this all wrong. I configured apache to only have one server process. Then using gdb, I connected to the server process and told it to continue execution. I then made a request to the server, causing it to crash. Heres what I got: Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 16384 (LWP 22572)] 0x4051cf58 in modperl_wbucket_flush () from /usr/lib/apache2/modules/mod_perl.so (gdb) backtrace #0 0x4051cf58 in modperl_wbucket_flush () from /usr/lib/apache2/modules/mod_perl.so #1 0x4066f5de in ?? () (gdb) generate-core-file Saved corefile core.22572 (gdb) quit # gdb /usr/sbin/apache2 core.22572 Gdb reported various libraries loading here #0 0x4051cf58 in modperl_wbucket_flush () from /usr/lib/apache2/modules/mod_perl.so (gdb) backtrace #0 0x4051cf58 in modperl_wbucket_flush () from /usr/lib/apache2/modules/mod_perl.so #1 0x4066f5de in XS_Apache__SubRequest_run () from /usr/local/lib/perl/5.8.0/auto/Apache/SubRequest/SubRequest.so #2 0x405ad7ef in Perl_pp_entersub () from /usr/lib/libperl.so.5.8 #3 0x405a720a in Perl_runops_standard () from /usr/lib/libperl.so.5.8 #4 0x4054fa32 in Perl_call_sv () from /usr/lib/libperl.so.5.8 #5 0x4054f837 in Perl_call_sv () from /usr/lib/libperl.so.5.8 #6 0x405195da in modperl_callback () from /usr/lib/apache2/modules/mod_perl.so #7 0x4051c7ae in modperl_run_filter () from /usr/lib/apache2/modules/mod_perl.so #8 0x4051cba7 in modperl_output_filter_handler () from /usr/lib/apache2/modules/mod_perl.so #9 0x0807e66b in ap_pass_brigade () #10 0x08084c15 in ap_core_translate () #11 0x08073b0a in ap_run_handler () #12 0x0807401e in ap_invoke_handler () #13 0x0806767f in ap_process_request () #14 0x080638ed in _start () #15 0x0815e3f8 in ?? () #16 0x0004 in ?? () #17 0x0815e3f8 in ?? () I have not included the core file here because it was ~ 3Mb If you need it please let me know -- Craig Shelley [EMAIL PROTECTED] -- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html
Problems Installing On Debian - Or Not
Hi All, It looked like the Debian install problems were back. [EMAIL PROTECTED]:~/temp/modperl-2.0$ perl Makefile.PL * WARNING * Your Perl is configured to link against libgdbm, but libgdbm.so was not found. You could just symlink it to /usr/lib/libgdbm.so.1.7.3 * WARNING * !!! Unable to open /mnt/general/temp/modperl-2.0/../../home/craig/temp/mod_perl-1.99_09/ap_release.h: No such file or directory !!! Unable to determine server version, aborting. !!! Please specify MP_APXS or MP_AP_PREFIX. I thought this was a bit strange, look at the path where it is trying to find my apache include dir. It should be looking in /usr/include/apache2/ Anyway, I do what it says... [EMAIL PROTECTED]:~/temp/modperl-2.0$ perl Makefile.PL MP_AP_PREFIX=/usr/include/apache2/ Reading Makefile.PL args from @ARGV MP_AP_PREFIX = /usr/include/apache2 * WARNING * Your Perl is configured to link against libgdbm, but libgdbm.so was not found. You could just symlink it to /usr/lib/libgdbm.so.1.7.3 * WARNING * !!! invalid MP_AP_PREFIX: include/ directory not found in /usr/include/apache2 Looked at first like I would have to frig the script... After analysing Build.pm, I noticed it was using a load of crap data from my old installation in /usr/local/lib/perl/5.8.0/Apache/BuildConfig.pm After deleting this file, i had to delete what i had got from cvs, and redownload. The second time round I ran into more problems... [EMAIL PROTECTED]:~/temp/modperl-2.0$ perl Makefile.PL * WARNING * Your Perl is configured to link against libgdbm, but libgdbm.so was not found. You could just symlink it to /usr/lib/libgdbm.so.1.7.3 * WARNING * !!! Unable to determine server version, aborting. !!! Please specify MP_APXS or MP_AP_PREFIX. Ok, so i specify the MP_AP_PREFIX option, since that was mentioned in the INSTALL file too. [EMAIL PROTECTED]:~/temp/modperl-2.0$ perl Makefile.PL MP_AP_PREFIX=/usr/include/apache2/ Reading Makefile.PL args from @ARGV MP_AP_PREFIX = /usr/include/apache2 * WARNING * Your Perl is configured to link against libgdbm, but libgdbm.so was not found. You could just symlink it to /usr/lib/libgdbm.so.1.7.3 * WARNING * !!! invalid MP_AP_PREFIX: include/ directory not found in /usr/include/apache2 Ah that problem again... SOLUTION: perl Makefile.PL MP_APXS=/usr/bin/apxs2 All problems went away. Problems occur in debian if the MP_AP_PREFIX is used because it expects a /include dir to be present. but if the MP_APXS option is not used, the MP_AP_PREFIX is one of the tempting recommendations by the script. The question here is, should the script have detected /usr/bin/apxs2 ? -- Craig Shelley [EMAIL PROTECTED] I hope the formatting of this email didn't come out too bad. -- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html
Re: SubRequest in Filter MP2 [QUESTION]
Hi All, On Wed, 2003-08-27 at 02:33, Geoffrey Young wrote: hi craig. before we continue, please try the latest cvs (without the patch I sent) and see if your stuff segfaults there. if not, at least we know we've isolated the segfault and just have bad logic to fix :) Well: It seg faulted again :( Here is what the log got: [Fri Aug 29 17:45:00 2003] [notice] child pid 14541 exit signal Segmentation fault (11) Here is a Backtrace: Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 16384 (LWP 14541)] 0x4052295c in modperl_wbucket_flush (wb=0x0, add_flush_bucket=0) at modperl_filter.c:180 180 if (wb-outcnt) { (gdb) backtrace #0 0x4052295c in modperl_wbucket_flush (wb=0x0, add_flush_bucket=0) at modperl_filter.c:180 #1 0x406801f2 in ?? () When i run gdb on the core file... #0 0x4052295c in modperl_wbucket_flush (wb=0x0, add_flush_bucket=0) at modperl_filter.c:180 180 if (wb-outcnt) { (gdb) backtrace #0 0x4052295c in modperl_wbucket_flush (wb=0x0, add_flush_bucket=0) at modperl_filter.c:180 #1 0x406801f2 in mpxs_ap_run_sub_req (my_perl=0x8148580, r=0x81a9418) at Apache__SubRequest.h:10 #2 0x406808da in XS_Apache__SubRequest_run (my_perl=0x8148580, cv=0x81965fc) at SubRequest.xs:83 #3 0x405bc7ef in Perl_pp_entersub () from /usr/lib/libperl.so.5.8 #4 0x405b620a in Perl_runops_standard () from /usr/lib/libperl.so.5.8 #5 0x4055ea32 in Perl_call_sv () from /usr/lib/libperl.so.5.8 #6 0x4055e837 in Perl_call_sv () from /usr/lib/libperl.so.5.8 #7 0x4051d6d5 in modperl_callback (my_perl=0x8148580, handler=0x80db808, p=0x815c920, r=0x815c958, s=0x80db858, args=0x8145598) at modperl_callback.c:53 #8 0x405231cd in modperl_run_filter (filter=0x8162938) at modperl_filter.c:400 #9 0x40523f51 in modperl_output_filter_handler (f=0x815e440, bb=0x815e5a8) at modperl_filter.c:761 #10 0x0807e66b in ap_pass_brigade () #11 0x08084c15 in ap_core_translate () #12 0x08073b0a in ap_run_handler () #13 0x0807401e in ap_invoke_handler () #14 0x0806767f in ap_process_request () #15 0x080638ed in _start () #16 0x0815c958 in ?? () #17 0x0004 in ?? () #18 0x0815c958 in ?? () If you would like some more info please let me know, because I am eager to help solve this problem. PS -- I am running the same test scripts as I mentioned in previous posts. -- Craig Shelley [EMAIL PROTECTED] -- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html
Re: SubRequest in Filter MP2 [QUESTION]
Hello.. Just Forwarding this to the list Having no idea as to how the internals of modperl and apache actually work, this may seem like a bit of a dumb suggestion. When doing a subrequest from within a filter, the most ideal situation would be to have access to the output from within the same filter. I don't know how this would be best done, but one example i can think of would be maybe to be given access to file handle which can be read from. The data from the subrequest can then be processed and incorporated as required. The reason I have ended up fiddling around with subrequests in filters is because i was originally writing a few extensions for SSI in MP1. My original plan was to create a small library of includable objects such as hit counters, fortune generators and photo albums etc The idea then was that other people with local access to my server can create simple html files that contain SSI directives to include the various objects. It was all going extremely well, until I tried to set a cookie from within a subrequest. After that, i ran into a whole load of trouble trying to capture the output from a subrequest, and ended up turning to mp2 I was wondering if there are any other avenues I should explore in order to set up such a system. Thank you for spending time on this problem I appreciate it greatly - On Thu, 2003-09-04 at 14:21, Geoffrey Young wrote: see Apache::SSI for mp1 - it does exactly what you are trying to do and is subclassable, so you can add your own tags/functionality if you want. After that, i ran into a whole load of trouble trying to capture the output from a subrequest see recipe 5.7 in the mod_perl developer's cookbook for that, or look at the Apache::SSI source, which does it a different way. -- Craig Shelley [EMAIL PROTECTED] Homepage: http://www.microtron.org.uk -- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html
Re: SubRequest in Filter MP2 [QUESTION]
Hello again.. On Thu, 2003-09-04 at 14:21, Geoffrey Young wrote: see Apache::SSI for mp1 - it does exactly what you are trying to do and is subclassable, so you can add your own tags/functionality if you want. That is exactly what I am already doing. When using #exec directive I noticed I could not set the headers properly. see recipe 5.7 in the mod_perl developer's cookbook for that, or look at the Apache::SSI source, which does it a different way. That is something i have yet to get my hands on! -- Craig Shelley [EMAIL PROTECTED] Homepage: http://www.microtron.org.uk -- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html
Reply to List
Hi, Just wondering why the mailing list has sets the list-post: header to [EMAIL PROTECTED] This can be quite annoying since mail clients like evolution have a Reply to List option which saves a lot of fafing about. Since the list email address appears to be wrong Reply to List cannot be used. I have a natural habit of using this feature, and end up with bounce messages like: Hi. This is the qmail-send program at apache.org. I'm afraid I wasn't able to deliver your message to the following addresses. This is a permanent error; I've given up. Sorry it didn't work out. [EMAIL PROTECTED]: This list is now [EMAIL PROTECTED] Thanks. --- Below this line is a copy of the message. Maybe it has not been updated? -- Craig Shelley [EMAIL PROTECTED] Homepage: http://www.microtron.org.uk -- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html