git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] gitweb: Add some mod_perl specific support

From
Jakub Narebski <jnareb@gmail.com>
Date
Dec 15, 2006, 21:18 UTC
Message-ID
<11662174851575-git-send-email-jnareb@gmail.com>

Add $r variable which holds Apache::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 Apache::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.

Use $r->path_info() instead of $ENV{"PATH_INFO"}.

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>
---
This is the same patch as previous
  'gitweb: Sprinkle some mod_perl goodies'
 gitweb/gitweb.perl |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 902c514..7df253c 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";
@@ -364,7 +371,7 @@ if (defined $searchtype) {
 # now read PATH_INFO and use it as alternative to parameters
 sub evaluate_path_info {
 	return if defined $project;
-	my $path_info = $ENV{"PATH_INFO"};
+	my $path_info = $r ? $r->path_info() : $ENV{"PATH_INFO"};
 	return if !$path_info;
 	$path_info =~ s,^/+,,;
 	return if !$path_info;
-- 
1.4.4.1
Next: Jakub Narebski
Message 1 of 5 in “gitweb: Add some mod_perl specific support”
  1. gitweb: Add some mod_perl specific supportJakub Narebski, Dec 15, 2006
  2. gitweb: Add some mod_perl specific supportJakub Narebski, Dec 16, 2006
  3. Junio C HamanoDec 16, 2006
  4. Jakub NarebskiDec 16, 2006
  5. Junio C HamanoDec 16, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.