{"thread":{"id":"43448","subject":"[RFC/PATCH (take 3)] gitweb: Add some mod_perl specific support","startedAt":"2006-12-15T21:18:05Z","lastAt":"2006-12-16T21:30:24Z","messageCount":5,"participants":["Jakub Narebski","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"295471","messageId":"11662174851575-git-send-email-jnareb@gmail.com","threadId":"43448","inReplyTo":null,"subject":"[PATCH] gitweb: Add some mod_perl specific support","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-12-15T21:18:05Z","receivedAt":"2006-12-15T21:18:05Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Add $r variable which holds Apache::RequestRec if script is run under\nmod_perl (if $ENV{MOD_PERL} is defined). It is used as argument to\nconstructor of CGI object (needs CGI module version at least 2.93).\nIt is needed for further mod_perl support, for example adding\nheaders using Apache::RequestRec methods instead of making Apache\nto have to parse headers (to add it's own HTTP headers like Server:\nheader).\n\nFollowing advice from CGI(3pm) man page, precompile all CGI routines\nfor mod_perl.\n\nUse $r->path_info() instead of $ENV{\"PATH_INFO\"}.\n\nAll this makes gitweb slightly faster under mod_perl (436 +/-  23.9 ms\nfor summary of git.git before, 429 +/- 12.0 ms after, according to\n'ab -n 10 -k \"http://localhost/perl/gitweb/gitweb.cgi?p=git.git\"').\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nThis is the same patch as previous\n  'gitweb: Sprinkle some mod_perl goodies'\n\n gitweb/gitweb.perl |   11 +++++++++--\n 1 files changed, 9 insertions(+), 2 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 902c514..7df253c 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -18,11 +18,18 @@ use File::Find qw();\n use File::Basename qw(basename);\n binmode STDOUT, ':utf8';\n \n-our $cgi = new CGI;\n+# mod_perl request\n+my $r;\n+$r = shift @_ if $ENV{MOD_PERL};\n+\n+our $cgi = new CGI($r);\n our $version = \"++GIT_VERSION++\";\n our $my_url = $cgi->url();\n our $my_uri = $cgi->url(-absolute => 1);\n \n+# speeding up mod_perl and FastCGI (later)\n+$cgi->compile() if $r;\n+\n # core git executable to use\n # this can just be \"git\" if your webserver has a sensible PATH\n our $GIT = \"++GIT_BINDIR++/git\";\n@@ -364,7 +371,7 @@ if (defined $searchtype) {\n # now read PATH_INFO and use it as alternative to parameters\n sub evaluate_path_info {\n \treturn if defined $project;\n-\tmy $path_info = $ENV{\"PATH_INFO\"};\n+\tmy $path_info = $r ? $r->path_info() : $ENV{\"PATH_INFO\"};\n \treturn if !$path_info;\n \t$path_info =~ s,^/+,,;\n \treturn if !$path_info;\n-- \n1.4.4.1\n"},{"id":"294840","messageId":"11662855752162-git-send-email-jnareb@gmail.com","threadId":"43448","inReplyTo":"11662174851575-git-send-email-jnareb@gmail.com","subject":"[RFC/PATCH (take 3)] gitweb: Add some mod_perl specific support","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-12-16T16:12:55Z","receivedAt":"2006-12-16T16:12:55Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Add $r variable which holds Apache2::RequestRec if script is run under\nmod_perl (if $ENV{MOD_PERL} is defined). It is used as argument to\nconstructor of CGI object (needs CGI module version at least 2.93).\nIt is needed for further mod_perl support, for example adding\nheaders using Apache2::RequestRec methods instead of making Apache\nto have to parse headers (to add it's own HTTP headers like Server:\nheader).\n\nFollowing advice from CGI(3pm) man page, precompile all CGI routines\nfor mod_perl.\n\nAll this makes gitweb slightly faster under mod_perl (436 +/-  23.9 ms\nfor summary of git.git before, 429 +/- 12.0 ms after, according to\n'ab -n 10 -k \"http://localhost/perl/gitweb/gitweb.cgi?p=git.git\"').\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nThe idea is to have gitweb run under CGI and under mod_perl 1.0 and 2.0\nwithout modifications, but making use of mod_perl features which make script\nfaster, like for example adding headers via mod_perl API and not via parsing\nheaders by Apache.  In the future the plan is to be able to run gitweb under\nnot only current ModPerl::Registry (or Apache::Registry in mod_perl 1.0) but\nalso as a mod_perl handler, and as a FastCGI script using CGI::Fast.\n\nCurrent portion of mod_perl cpecific additions is mod_perl version agnostic,\nand avoids loading any mod_perl Perl modules.\n\nI'd like to have it (and further mod_perl patches) reviewed by someone\nbetter versed in mod_perl.\n\n gitweb/gitweb.perl |    9 ++++++++-\n 1 files changed, 8 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 902c514..f834c64 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -18,11 +18,18 @@ use File::Find qw();\n use File::Basename qw(basename);\n binmode STDOUT, ':utf8';\n \n-our $cgi = new CGI;\n+# mod_perl request\n+my $r;\n+$r = shift @_ if $ENV{MOD_PERL};\n+\n+our $cgi = new CGI($r);\n our $version = \"++GIT_VERSION++\";\n our $my_url = $cgi->url();\n our $my_uri = $cgi->url(-absolute => 1);\n \n+# speeding up mod_perl and FastCGI (later)\n+$cgi->compile() if $r;\n+\n # core git executable to use\n # this can just be \"git\" if your webserver has a sensible PATH\n our $GIT = \"++GIT_BINDIR++/git\";\n-- \n1.4.4.1\n"},{"id":"297516","messageId":"7virgbei6z.fsf@assigned-by-dhcp.cox.net","threadId":"43448","inReplyTo":"11662855752162-git-send-email-jnareb@gmail.com","subject":"Re: [RFC/PATCH (take 3)] gitweb: Add some mod_perl specific support","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-16T19:47:48Z","receivedAt":"2006-12-16T19:47:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I have your (take 2) merged already last night in my tree but\nhaven't pushed the result out.  Does this replace it?\n"},{"id":"297856","messageId":"200612162103.18695.jnareb@gmail.com","threadId":"43448","inReplyTo":"7virgbei6z.fsf@assigned-by-dhcp.cox.net","subject":"Re: [RFC/PATCH (take 3)] gitweb: Add some mod_perl specific support","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-12-16T20:03:17Z","receivedAt":"2006-12-16T20:03:17Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano wrote:\n> I have your (take 2) merged already last night in my tree but\n> haven't pushed the result out.  Does this replace it?\n\nYes, that replaces it. I'm very sorry for the confusion.\n\nI have noticed that I would need to add \"use Apache2::RequestRec\"\nor it's mod_perl 1.0 equivalent before I can use $r->path_info().\n-- \nJakub Narebski\n"},{"id":"297883","messageId":"7vwt4rcyvj.fsf@assigned-by-dhcp.cox.net","threadId":"43448","inReplyTo":"200612162103.18695.jnareb@gmail.com","subject":"Re: [RFC/PATCH (take 3)] gitweb: Add some mod_perl specific support","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-16T21:30:24Z","receivedAt":"2006-12-16T21:30:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> Junio C Hamano wrote:\n>> I have your (take 2) merged already last night in my tree but\n>> haven't pushed the result out.  Does this replace it?\n>\n> Yes, that replaces it. I'm very sorry for the confusion.\n>\n> I have noticed that I would need to add \"use Apache2::RequestRec\"\n> or it's mod_perl 1.0 equivalent before I can use $r->path_info().\n\nI noticed the difference by applying the patch to the parent of\n(take 2) commit I made and diffing.  It would be nice to have\nthe above two line comment somewhere in the message, probably\nimmediately after the three-dash lines, but no biggie.\n\nThanks for the clarification.\n"}]}