ANNOUNCE: Apache2::RequestRec::Time 1.0
The uploaded file Apache2-RequestRec-Time-1.0.tar.gz has entered CPAN as file: $CPAN/authors/id/J/JA/JANPAZ/Apache2-RequestRec-Time-1.0.tar.gz size: 3370 bytes md5: 2c08dc68bfeeae47c8df2eae87f3b22d README As of mod_perl 2.0.4, it is possible to get request duration information by substracting current time from $r->request_time(). However, that information is in seconds, so it's not possible to get the equivalent of Custom Log Format %D -- the time taken to serve the request, in microseconds. This module adds $r->request_duration_microseconds() method, and a couple of utility methods. NAME Apache2::RequestRec::Time - Bring microseconds to Apache2::RequestRec SYNOPSIS use Apache2::RequestRec::Time (); # have Apache2::RequestRec object $r my $duration = $r->request_duration_microseconds(); DESCRIPTION The Apache2::RequestRec::Time extends the Apache2::RequestRec functionality with method request_duration_microseconds(). That makes it possible to retrieve from Perl information equivalent to Custom Log Format’s %D: the time taken to serve the request, in microseconds. API request_duration_microseconds($r) Parameters: $r: Apache2::RequestRec object Returns: time taken to serve the request, in microseconds. Actually, it’s time since $r->request_time(). It is equivalent to %D in Custom Log Formats. request_duration($r) Parameters: $r: Apache2::RequestRec object Returns: time taken to serve the request, in seconds. Equivalent to %T in Custom Log Formats. request_time_microseconds($r) Parameters: $r: Apache2::RequestRec object Returns: time the request was received, in microseconds since epoch. This is microsecond-ish variant of $r->request_time(). Enjoy. Comments welcome. -- Jan Pazdziora
Re: [ANNOUNCE] Introducing GX
On Tue, Sep 20, 2011 at 03:49:53PM +0200, Jörg A. Uzarek wrote: > I am happy to announce the first public (developer) release of GX, a web > application framework that is designed from the ground up to be run in > persistent environments like mod_perl (or FastCGI). > > You can download the (pre-alpha) release from CPAN: > > http://search.cpan.org/~jau/GX-0.2000_01/ > > or from the GX Framework website: > > http://gxframework.org/downloads/ > > I have also set up a public git repository at: > > http://git.gxframework.org > > A (pathetic excuse for a) quick start tutorial is available here: > > http://gxframework.org/documentation/tutorials/quickstart/ > > Please give it a try and post feedback here or on the GX Framework mailing > list (http://groups.google.com/group/gxframework). Additional contact > information for reporting bugs, etc. can be found in the POD. Hello Jörg, three questions -- there already seems to be a GX framework for JS animation: http://gx.riccardodegni.net/ http://code.google.com/p/gxframework/ Aren't you affraid of namespace clash? The tutorial is nice but it's mostly a get-mod_perl-running tutorial -- the resulting application is what seems to be just a static welcome.html there. Any more complex example application, showing some Perl code executed, and database accessed? The GX man page it lacking the relationship explanation as well. Can you provide some high level comparison to (say) Catalyst? Surely there was a reason to come up with yet another web application framework, so what are the selling points? Thanks, -- Jan Pazdziora
Re: how to run regex calculation
On Thu, Jan 09, 2020 at 05:21:38PM +0800, Wesley Peng wrote: > what does (??{$1*$2}) means? Check the perlre(1) man page for explanation of "(??{ code })". As already mentioned, other venues like Perlmonks might serve better for the generic Perl questions. -- Jan Pazdziora
PerlOpenLogsHandler, END, Devel::Cover, and coredump
Hello, I'm getting segfaults when I use module which has an END {} block as PerlOpenLogsHandler or PerlPostConfigHandler with Devel::Cover. I found the problem when I used DBI in my PerlOpenLogsHandler but even small module with an END block shows the same behaviour. Here's what I have: Makefile.PL: use ExtUtils::MakeMaker; use Apache::TestMM qw(clean test); Apache::TestMM::filter_args(); Apache::TestMM::generate_script('t/TEST'); WriteMakefile( NAME => 'mod_perl-end-devel-cover-test', PREREQ_PM => { 'Apache2::Const' => 0, 'Test' => 0, 'Test::More' => 0, 'Devel::Cover' => 0, }, ); lib/TestEND.pm: package TestEND; sub handler { return 0; } END { print STDERR "END\n"; } 1; __END__ t/conf/extra.conf.in: PerlSwitches -...@serverroot@/../lib PerlOpenLogsHandler TestEND t/1.t: use Test; plan tests => 1; ok(1); t/TEST.PL: use Apache::TestRunPerl (); Apache::TestRunPerl->new->run(@ARGV); I can run make test just fine. When I run make testcover TEST_VERBOSE=1, I get waiting 60 seconds for server to start: .[ error] server has died with status 255 (please examine t/logs/error_log) [ error] oh nuts, server dumped core [ error] for stacktrace, run: gdb /usr/sbin/httpd -core /home/adelton/project/mod_perl-end-devel-cover/core.14876 sh: line 1: 14749 Terminated /usr/bin/perl /home/adelton/project/mod_perl-end-devel-cover/t/TEST -one-process -bugreport -verbose=1 The backtrace is #0 Perl_pp_entersub (my_perl=0x24a61b8) at pp_hot.c:2643 #1 0x010a5cf3 in Perl_call_sv (my_perl=0x24a61b8, sv=0x20, flags=6) at perl.c:2653 #2 0x00a19b3e in modperl_perl_call_list (my_perl=0x24a61b8, subs=0x29d8d94, name=0xa3d281 "END") at modperl_util.c:483 #3 0x00a26068 in modperl_perl_call_endav (my_perl=0x24a61b8) at modperl_perl.c:199 #4 0x00a260c5 in modperl_perl_destruct (perl=0x24a61b8) at modperl_perl.c:142 #5 0x00a0f725 in modperl_interp_destroy (interp=0x24cfff8) at modperl_interp.c:146 #6 0x00a0f7e1 in modperl_interp_pool_destroy (data=0x249e2c0) at modperl_interp.c:202 #7 0x0069ead9 in run_cleanups () at memory/unix/apr_pools.c:2306 #8 apr_pool_destroy (pool=0x24a21c0) at memory/unix/apr_pools.c:774 #9 0x0069ed98 in apr_pool_clear (pool=0x2333638) at memory/unix/apr_pools.c:728 #10 0x009be6b0 in main (argc=1650552405, argv=0xbf8e85c4) at /usr/src/debug/httpd-2.2.11/server/main.c:690 and the error_log has [Fri May 15 21:20:21 2009] [notice] SELinux policy enabled; httpd running as context unconfined_u:unconfined_r:unconfined_t:s0 END So the END block is executed but the restart of the apache server (the one which happens after PerlPostConfigHandler) fails. The problem does not occur when the module is used as PerlHandler. The problem does not occur without Devel::Cover. The versions of software are httpd-2.2.11-2.fc10.i386 mod_perl-2.0.4-7.i386 perl-5.10.0-68.fc10.i386 perl-Devel-Cover-0.64-1.fc10.i386 -- I'm using packages from Fedora 10, not compiled by myself. Have you got any hints what could be the problem or where to start looking for the cause of the segfault? Thanks, -- Jan Pazdziora
Re: Custom PerlResponseHandler for a subrequest
On Tue, Jun 04, 2024 at 03:35:06PM +0200, Jan Kasprzak wrote: > Hello, > > I am trying to do something like this in PerlAuthenHandler, > and it mostly works: > > sub auth_handler { > my ($r) = @_; > ... > if ($cond) { > $r->set_handlers(PerlResponseHandler => sub { > my ($r) = @_; > $r->content_type('text/plain'); > $r->print("custom handler was here\n"); > return Apache2::Const::OK; > }); > $r->user('dummy-user-for-a-dummy-handler'); > return Apache2::Const::OK; > } > ... > } > > when $cond happens, I get 200 OK with "custom handler was here" > instead of whatever is configured as PerlResponseHandler in httpd.conf. > So far good. [...] > Then for requests meeting $cond above I get the following: > > https://example.com/directory -> 302 to /directory/ (trailing slash, OK) > https://example.com/directory/ -> 200 with custom handler as expected > https://example.com/directory/index.pl -> 200 with custom handler as expected > https://example.com/directory/index -> 200 from My::Ordinary::Handler - FAIL > https://example.com/directory/foo.pl -> 200 with custom handler as expected > https://example.com/directory/foo -> 200 from My::Ordinary::Handler - FAIL > > It seems that the auth_handler gets called for all the above requests, > but for the failed ones mod_rewrite creates subrequests, which do not inherit > the custom PerlResponseHandler set by auth_handler(). How can I replace > a PerlResponseHandler even for a subrequest? Or how can I tap to a subrequest > creation? Or how can I bypass mod_rewrite from within the PerlAuthenHandler > and return my own 200 OK response immediately? Are you able to check / configure some logging to see if that auth_handler was called at all in the redirect / subrequest case, and if the $cond was found true there? Do you still see the dummy-user-for-a-dummy-handler logged (with My::Ordinary::Handler content), or is that user information missing as well? How is that auth_handler configured / enabled anyway? -- Jan Pazdziora