Skip to content

Instantly share code, notes, and snippets.

@petr999
Created January 16, 2010 12:06
Show Gist options
  • Save petr999/278799 to your computer and use it in GitHub Desktop.
Save petr999/278799 to your computer and use it in GitHub Desktop.
--- bugzilla.orig/Bugzilla/CGI.pm 2010-01-09 20:39:11.000000000 +0400
+++ bugzilla/Bugzilla/CGI.pm 2010-01-12 00:02:14.811537343 +0400
@@ -35,7 +35,7 @@
use CGI qw(-no_xhtml -oldstyle_urls :private_tempfiles :unique_headers SERVER_PUSH);
-use base qw(CGI);
+use base qw(CGI::Fast);
use Bugzilla::Constants;
use Bugzilla::Error;
@@ -63,7 +63,7 @@
my ($invocant, @args) = @_;
my $class = ref($invocant) || $invocant;
- my $self = $class->SUPER::new(@args);
+ my $self = bless new CGI, $class;
# Make sure our outgoing cookie list is empty on each invocation
$self->{Bugzilla_cookie_list} = [];
sub the_callout {
do shift;
map{ delete Bugzilla->request_cache->{$_} } grep { $_ ne 'params' } keys %{ Bugzilla->request_cache };
}
# this is to be used in conjunction with
# clean_inc_subnamespace => 'Bugzilla::Config'
# and the new save_env feature
# to avoid fork exiting after max_requests put this into the
# BEGIN{
# ...
*CORE::GLOBAL::exit = sub {
last CALLED_OUT;
}
# ...
#}
sub the_callout {
do shift;
CALLED_OUT: $Bugzilla::_request_cache = {}; # to be used with
# clean_inc_subnamespace => 'Bugzilla::Config'}
# in the FCGI::Spawn->new(); and config is
# to be re-read on each request
}
# ...
my $spawn = FCGI::Spawn->new();
# ...
# to import modules for sharing afterwards
map {
$FCGI::Spawn::fcgi = new CGI; $spawn->callout( $_, $FCGI::Spawn::fcgi ) ; undef $CGI::Q;
}( $webguiRoot.'/../www/index.pl', $bugzillaRoot.'/index.cgi', );
undef $FCGI::Spawn::fcgi;
# Bugzilla.pm is imported for request cache and database handle cleaning
our %SAVE_ENV = %ENV; eval " use Bugzilla; " ; die $@ if $@; %ENV = %SAVE_ENV; undef %SAVE_ENV;
#
# You need one of two those lines below to keep from errors on fork()ed database
# handles those known not to work after the fork().
#
# with mysql, auto_reconnect feature is useful for persistent forks. You may not have
# such an option for other DBD/DBMS software.
eval 'Bugzilla->dbh->{mysql_auto_reconnect} = 1;' ; die $@ if $@;
# This is to drop out database handles before fork()s, somewhy $_request_cache is undef()'d
# in Bugzilla::_cleanup, need to define it after that.
eval 'Bugzilla::_cleanup; $Bugzilla::_request_cache={};' ; die $@ if $@;
# ...
$spawn->spawn();
# ...
# Nginx config, the server{} section internals
charset utf-8;
root /var/www/bugzilla;
location ~ /\.ht.*|.*(localconfig.*|\.p[ml])$ {
deny all;
}
location /Bugzilla { deny all; }
location ~ ^/data/webdot/[^/].*\.dot$ { deny all; }
location ~ ^/data/attachments/[^/]* { deny all; }
location = /data/duplicates.rdf { allow all; }
location ~ ^/data/[^/]* { deny all; }
location ~ \.cgi$ {
fastcgi_pass unix:/tmp/spawner.sock;
}
if ($uri ~ "^(.*\.(pl|cgi))(/.+)?$") {
set $unpath_script_name $1;
set $path_info $3;
}
location /docs/ {
alias /usr/local/share/doc/bugzilla/;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment