[freeside-commits] branch master updated. 22a1feb55c4bb705064a04646ff5c321b8112ce1

Ivan ivan at 420.am
Tue Jun 12 04:03:15 PDT 2012


The branch, master has been updated
       via  22a1feb55c4bb705064a04646ff5c321b8112ce1 (commit)
      from  dc058e6549b8353ae16e8a1b3f6d88b667d5c8d9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 22a1feb55c4bb705064a04646ff5c321b8112ce1
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue Jun 12 04:03:14 2012 -0700

    possibly fix intermittent "could not receive data from server: Bad file

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; #?
diff --git a/htetc/handler.pl b/htetc/handler.pl
index b00ab6d..cea3661 100644
--- a/htetc/handler.pl
+++ b/htetc/handler.pl
@@ -84,7 +84,7 @@ sub handler
       local $SIG{__WARN__};
       local $SIG{__DIE__};
 
-      RT::Init();
+      my_rt_init();
 
       $ah->interp($rt_interp);
 
@@ -93,7 +93,7 @@ sub handler
       local $SIG{__WARN__};
       local $SIG{__DIE__};
 
-      RT::Init() if $RT::VERSION; #for lack of something else
+      my_rt_init();
 
       #we don't want the RT error handlers under FS
       {
@@ -128,4 +128,19 @@ sub handler
     $status;
 }
 
+my $rt_initialized = 0;
+
+sub my_rt_init {
+  return unless $RT::VERSION;
+
+  if ( $rt_initialized ) {
+    RT::ConnectToDatabase();
+    RT::InitSignalHandlers();
+  } else {
+    RT::LoadConfig();
+    RT::Init();
+    $rt_initialized++;
+  }
+}
+
 1;

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Mason/Request.pm |   19 +++++++++++++++++++
 htetc/handler.pl       |   19 +++++++++++++++++--
 2 files changed, 36 insertions(+), 2 deletions(-)




More information about the freeside-commits mailing list