should fix intermittant slowness, RT#18719
authorIvan Kohler <ivan@freeside.biz>
Mon, 13 Aug 2012 20:00:41 +0000 (13:00 -0700)
committerIvan Kohler <ivan@freeside.biz>
Mon, 13 Aug 2012 20:00:41 +0000 (13:00 -0700)
Makefile
htetc/handler.pl

index 864d9c2..903c0eb 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -170,6 +170,7 @@ install-docs: check-conflicts docs
        cp htetc/handler.pl ${MASON_HANDLER}
        perl -p -i -e "\
          s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
+         s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \
        " ${MASON_HANDLER} || true
        mkdir -p ${FREESIDE_EXPORT}/profile
        chown freeside ${FREESIDE_EXPORT}/profile
index 2e6fbe5..d7c5657 100644 (file)
@@ -7,6 +7,14 @@ use warnings;
 use FS::Mason qw( mason_interps );
 use FS::Trace;
 
+if ( %%%RT_ENABLED%%% ) {
+  require RT;
+  $> = scalar(getpwnam('freeside'));
+  RT::LoadConfig();
+  RT::Init();
+  $> = $<;
+}
+
 #use vars qw($r);
 
 # Bring in ApacheHandler, necessary for mod_perl integration.
@@ -151,19 +159,10 @@ 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++;
-  }
+  RT::ConnectToDatabase();
+  RT::InitSignalHandlers();
 }
 
 1;