X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=htetc%2Fhandler.pl;h=f41a3df704104b348d4c8554e20636d84c2543b5;hb=ebd89c7672e0bf5150fe1c2f89c2f88b90304e8d;hp=77b93463fedbe25bbf365dea3922f32dc6d0ff25;hpb=07d63243b070962b8fcf8e6b59128ccf1305f8f8;p=freeside.git diff --git a/htetc/handler.pl b/htetc/handler.pl index 77b93463f..f41a3df70 100644 --- a/htetc/handler.pl +++ b/htetc/handler.pl @@ -6,6 +6,24 @@ use strict; use warnings; use FS::Mason qw( mason_interps ); use FS::Trace; +use FS::access_user_log; + +if ( %%%RT_ENABLED%%% ) { + + require RT; + + $> = scalar(getpwnam('freeside')); + + RT::LoadConfig(); + RT::Init(); + + # disconnect DB before fork: + # (avoid 'prepared statement "dbdpg_p\d+_\d+" already exists' errors?) + $RT::Handle->dbh(undef); + undef $RT::Handle; + + $> = $<; +} #use vars qw($r); @@ -87,7 +105,6 @@ sub handler return -1 if defined( $r->content_type ) && $r->content_type !~ m!(^text/|\bxml\b)!io; - local $SIG{__WARN__}; local $SIG{__DIE__}; @@ -119,6 +136,8 @@ sub handler } + FS::access_user_log->insert_new_path( $r->uri ); + FS::Trace->log('handling request'); my %session; my $status; @@ -141,7 +160,9 @@ sub handler FS::Trace->log('done'); - FS::Trace->dumpfile("%%%FREESIDE_EXPORT%%%/profile/$$.".time, $r->filename) + FS::Trace->dumpfile( "%%%FREESIDE_EXPORT%%%/profile/$$.".time, + FS::Trace->total. ' '. $r->filename + ) if FS::Trace->total > 5; #10? FS::Trace->reset; @@ -149,19 +170,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;