[Rt-commit] rt branch, new-webmux, updated. rt-3.8.6-106-g3a86d47
Ruslan Zakirov
ruz at bestpractical.com
Sun Nov 22 18:31:42 EST 2009
The branch, new-webmux has been updated
via 3a86d47860451911be843a0fb047e6f6088f8e72 (commit)
via f769543e4bbf07ac994d013a0b9b5c7d1081d386 (commit)
via 3044dd383d3752fe8845d143ea60119e71538109 (commit)
via 5dd14e194131c21a83cc78eec6782b749bdbe8d2 (commit)
via a452625c6205c02c7c3871c8cb56a511115b8265 (commit)
from 593a9495d5385e9a42eb21ce61cb19b75033d72c (commit)
Summary of changes:
bin/mason_handler.fcgi.in | 25 +++++++++++--------------
bin/mason_handler.scgi.in | 7 +------
lib/RT/Crypt/GnuPG.pm | 26 +++++++++++++-------------
lib/RT/Util.pm | 36 ++++++++++++++++++++++++++++++++++++
4 files changed, 61 insertions(+), 33 deletions(-)
- Log -----------------------------------------------------------------
commit a452625c6205c02c7c3871c8cb56a511115b8265
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sat Nov 21 03:06:54 2009 +0300
don't create handles we don't need, we can hit limit
diff --git a/lib/RT/Crypt/GnuPG.pm b/lib/RT/Crypt/GnuPG.pm
index 5581df1..40fd477 100644
--- a/lib/RT/Crypt/GnuPG.pm
+++ b/lib/RT/Crypt/GnuPG.pm
@@ -2411,16 +2411,10 @@ sub Probe {
sub _make_gpg_handles {
- my %handle_map = (
- stdin => IO::Handle->new(),
- stdout => IO::Handle->new(),
- stderr => IO::Handle->new(),
- logger => IO::Handle->new(),
- status => IO::Handle->new(),
- command => IO::Handle->new(),
-
-
- @_);
+ my %handle_map = (@_);
+ $handle_map{$_} = IO::Handle->new
+ foreach grep !defined $handle_map{$_},
+ qw(stdin stdout stderr logger status command);
my $handles = GnuPG::Handles->new(%handle_map);
return ($handles, \%handle_map);
commit 5dd14e194131c21a83cc78eec6782b749bdbe8d2
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sat Nov 21 03:08:10 2009 +0300
more debug from gpg probe
diff --git a/lib/RT/Crypt/GnuPG.pm b/lib/RT/Crypt/GnuPG.pm
index 40fd477..b8e2cb2 100644
--- a/lib/RT/Crypt/GnuPG.pm
+++ b/lib/RT/Crypt/GnuPG.pm
@@ -2399,11 +2399,17 @@ sub Probe {
# it's general error system error or incorrect command, command is correct,
# but there is no way to get actuall error
if ( $? && ($? >> 8) != 2 ) {
- $RT::Logger->debug(
- "Probe for GPG failed."
+ my $msg = "Probe for GPG failed."
." Process exitted with code ". ($? >> 8)
. ($? & 127 ? (" as recieved signal ". ($? & 127)) : '')
- );
+ . ".";
+ foreach ( qw(stderr logger status) ) {
+ my $tmp = do { local $/; readline $handle{$_} };
+ next unless $tmp && $tmp =~ /\S/s;
+ close $handle{$_};
+ $msg .= "\n$_:\n$tmp\n";
+ }
+ $RT::Logger->debug( $msg );
return 0;
}
return 1;
commit 3044dd383d3752fe8845d143ea60119e71538109
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sat Nov 21 03:12:38 2009 +0300
fix safe_run_child when code dies between fork and exec
diff --git a/lib/RT/Util.pm b/lib/RT/Util.pm
index dd15721..03d27a3 100644
--- a/lib/RT/Util.pm
+++ b/lib/RT/Util.pm
@@ -54,6 +54,42 @@ use base 'Exporter';
our @EXPORT = qw/safe_run_child/;
sub safe_run_child (&) {
+ my $our_pid = $$;
+
+ # situation here is wierd, running external app
+ # involves fork+exec. At some point after fork,
+ # but before exec (or during) code can die in a
+ # child. Local is no help here as die throws
+ # error out of scope and locals are reset to old
+ # values. Instead we set values, eval code, check pid
+ # on failure and reset values only in our original
+ # process
+ my $dbh = $RT::Handle->dbh;
+ $dbh->{'InactiveDestroy'} = 1 if $dbh;
+ $RT::Handle->{'DisconnectHandleOnDestroy'} = 0;
+
+ my @res;
+ my $want = wantarray;
+ eval {
+ unless ( defined $want ) {
+ _safe_run_child( @_ );
+ } elsif ( $want ) {
+ @res = _safe_run_child( @_ );
+ } else {
+ @res = ( scalar _safe_run_child( @_ ) );
+ }
+ 1;
+ } or do {
+ if ( $our_pid == $$ ) {
+ $dbh->{'InactiveDestroy'} = 0 if $dbh;
+ $RT::Handle->{'DisconnectHandleOnDestroy'} = 1;
+ }
+ die $@;
+ };
+ return $want? (@res) : $res[0];
+}
+
+sub _safe_run_child {
local @ENV{ 'LANG', 'LC_ALL' } = ( 'C', 'C' );
return shift->() if $ENV{'MOD_PERL'} || $CGI::SpeedyCGI::i_am_speedy;
commit f769543e4bbf07ac994d013a0b9b5c7d1081d386
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sat Nov 21 03:25:05 2009 +0300
get rid of some things we don't need anymore
diff --git a/bin/mason_handler.fcgi.in b/bin/mason_handler.fcgi.in
index 48155f2..baf407d 100755
--- a/bin/mason_handler.fcgi.in
+++ b/bin/mason_handler.fcgi.in
@@ -46,23 +46,16 @@
# those contributions and any derivatives thereof.
#
# END BPS TAGGED BLOCK }}}
-package RT::Mason;
-
use strict;
-use vars '$Handler';
-use File::Basename;
+use warnings;
+no warnings qw(once);
-require (dirname(__FILE__) . '/webmux.pl');
+use File::Basename;
+require (dirname(__FILE__) .'/webmux.pl');
# Enter CGI::Fast mode, which should also work as a vanilla CGI script.
require CGI::Fast;
-RT::Init();
-$Handler ||= RT::Interface::Web::Handler->new(
- RT->Config->Get('MasonParameters')
-);
-
-
while ( my $cgi = CGI::Fast->new ) {
# the whole point of fastcgi requires the env to get reset here..
# So we must squash it again
@@ -75,12 +68,16 @@ while ( my $cgi = CGI::Fast->new ) {
Module::Refresh->refresh if RT->Config->Get('DevelMode');
RT::ConnectToDatabase();
- if ( ( !$Handler->interp->comp_exists( $cgi->path_info ) )
- && ( $Handler->interp->comp_exists( $cgi->path_info . "/index.html" ) ) ) {
+ my $interp = $RT::Mason::Handler->interp;
+ if (
+ !$interp->comp_exists( $cgi->path_info )
+ && $interp->comp_exists( $cgi->path_info . "/index.html" )
+ ) {
$cgi->path_info( $cgi->path_info . "/index.html" );
}
- eval { $Handler->handle_cgi_object($cgi); };
+ local $@;
+ eval { $RT::Mason::Handler->handle_cgi_object($cgi); };
if ($@) {
$RT::Logger->crit($@);
}
commit 3a86d47860451911be843a0fb047e6f6088f8e72
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sat Nov 21 17:20:27 2009 +0300
port scgi handler to new code
diff --git a/bin/mason_handler.scgi.in b/bin/mason_handler.scgi.in
index a853529..cd24bc8 100755
--- a/bin/mason_handler.scgi.in
+++ b/bin/mason_handler.scgi.in
@@ -56,18 +56,13 @@ require (dirname(__FILE__) . '/webmux.pl');
require CGI;
-RT::Init();
-$Handler ||= RT::Interface::Web::Handler->new(
- RT->Config->Get('MasonParameters')
-);
-
-
my $cgi = CGI->new;
if ( ( !$Handler->interp->comp_exists( $cgi->path_info ) )
&& ( $Handler->interp->comp_exists( $cgi->path_info . "/index.html" ) ) ) {
$cgi->path_info( $cgi->path_info . "/index.html" );
}
+RT::ConnectToDatabase();
$Handler->handle_cgi_object($cgi);
RT::Interface::Web::Handler->CleanupRequest();
1;
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list