summaryrefslogtreecommitdiff
path: root/FS/FS/Mason
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2012-06-12 04:03:14 -0700
committerIvan Kohler <ivan@freeside.biz>2012-06-12 04:03:14 -0700
commit22a1feb55c4bb705064a04646ff5c321b8112ce1 (patch)
treef2690f9f6af03724d5eaf2ef12b35674e6e4a92a /FS/FS/Mason
parentdc058e6549b8353ae16e8a1b3f6d88b667d5c8d9 (diff)
possibly fix intermittent "could not receive data from server: Bad file
Diffstat (limited to 'FS/FS/Mason')
-rw-r--r--FS/FS/Mason/Request.pm19
1 files changed, 19 insertions, 0 deletions
diff --git a/FS/FS/Mason/Request.pm b/FS/FS/Mason/Request.pm
index d8fd77a..0d21df4 100644
--- a/FS/FS/Mason/Request.pm
+++ b/FS/FS/Mason/Request.pm
@@ -33,9 +33,28 @@ sub new {
#override alter_superclass ala RT::Interface::Web::Request ??
# for Mason 1.39 vs. Perl 5.10.0
+my $protect_fds;
+
sub freeside_setup {
my( $class, $filename, $mode ) = @_;
+ #from rt/bin/webmux.pl(.in)
+ if ( !$protect_fds && $ENV{'MOD_PERL'} && exists $ENV{'MOD_PERL_API_VERSION'}
+ && $ENV{'MOD_PERL_API_VERSION'} >= 2
+ ) {
+ # under mod_perl2, STDIN and STDOUT get closed and re-opened,
+ # however they are not on FD 0 and 1. In this case, the next
+ # socket that gets opened will occupy one of these FDs, and make
+ # all system() and open "|-" calls dangerous; for example, the
+ # DBI handle can get this FD, which later system() calls will
+ # close by putting garbage into the socket.
+ $protect_fds = [];
+ push @{$protect_fds}, IO::Handle->new_from_fd(0, "r")
+ if fileno(STDIN) != 0;
+ push @{$protect_fds}, IO::Handle->new_from_fd(1, "w")
+ if fileno(STDOUT) != 1;
+ }
+
if ( $filename =~ qr(/REST/\d+\.\d+/NoAuth/) ) {
package HTML::Mason::Commands; #?