From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Cc: Jakub Narebski <jnareb@gmail.com>
Subject: [RFC/PATCH (take 3)] gitweb: Add some mod_perl specific support
Date: Sat, 16 Dec 2006 17:12:55 +0100 [thread overview]
Message-ID: <11662855752162-git-send-email-jnareb@gmail.com> (raw)
In-Reply-To: <11662174851575-git-send-email-jnareb@gmail.com>
Add $r variable which holds Apache2::RequestRec if script is run under
mod_perl (if $ENV{MOD_PERL} is defined). It is used as argument to
constructor of CGI object (needs CGI module version at least 2.93).
It is needed for further mod_perl support, for example adding
headers using Apache2::RequestRec methods instead of making Apache
to have to parse headers (to add it's own HTTP headers like Server:
header).
Following advice from CGI(3pm) man page, precompile all CGI routines
for mod_perl.
All this makes gitweb slightly faster under mod_perl (436 +/- 23.9 ms
for summary of git.git before, 429 +/- 12.0 ms after, according to
'ab -n 10 -k "http://localhost/perl/gitweb/gitweb.cgi?p=git.git"').
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
The idea is to have gitweb run under CGI and under mod_perl 1.0 and 2.0
without modifications, but making use of mod_perl features which make script
faster, like for example adding headers via mod_perl API and not via parsing
headers by Apache. In the future the plan is to be able to run gitweb under
not only current ModPerl::Registry (or Apache::Registry in mod_perl 1.0) but
also as a mod_perl handler, and as a FastCGI script using CGI::Fast.
Current portion of mod_perl cpecific additions is mod_perl version agnostic,
and avoids loading any mod_perl Perl modules.
I'd like to have it (and further mod_perl patches) reviewed by someone
better versed in mod_perl.
gitweb/gitweb.perl | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 902c514..f834c64 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -18,11 +18,18 @@ use File::Find qw();
use File::Basename qw(basename);
binmode STDOUT, ':utf8';
-our $cgi = new CGI;
+# mod_perl request
+my $r;
+$r = shift @_ if $ENV{MOD_PERL};
+
+our $cgi = new CGI($r);
our $version = "++GIT_VERSION++";
our $my_url = $cgi->url();
our $my_uri = $cgi->url(-absolute => 1);
+# speeding up mod_perl and FastCGI (later)
+$cgi->compile() if $r;
+
# core git executable to use
# this can just be "git" if your webserver has a sensible PATH
our $GIT = "++GIT_BINDIR++/git";
--
1.4.4.1
next prev parent reply other threads:[~2006-12-16 16:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-15 21:18 [PATCH] gitweb: Add some mod_perl specific support Jakub Narebski
2006-12-16 16:12 ` Jakub Narebski [this message]
2006-12-16 19:47 ` [RFC/PATCH (take 3)] " Junio C Hamano
2006-12-16 20:03 ` Jakub Narebski
2006-12-16 21:30 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11662855752162-git-send-email-jnareb@gmail.com \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).