[freeside-commits] branch master updated. 59fe7dfd7fa6d31c30f3458af05510041ba529e0

Ivan ivan at 420.am
Tue Feb 24 19:01:00 PST 2015


The branch, master has been updated
       via  59fe7dfd7fa6d31c30f3458af05510041ba529e0 (commit)
       via  688288d7c60a648519d3b0127cd9286401078204 (commit)
       via  24bdd2d7ec485534761891bd1b0c42f14c11435a (commit)
       via  ae02d1178c6859f7a0a5e4a22c685de5f0477568 (commit)
      from  322bb305ccb724f35e869b757e9bb5fa4a468e84 (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 59fe7dfd7fa6d31c30f3458af05510041ba529e0
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue Feb 24 19:00:51 2015 -0800

    avoid warnings in all non-web UI code with new conf cache, github#38, RT#33683

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index e204747..838b9cb 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -23,6 +23,8 @@ $base_dir = '%%%FREESIDE_CONF%%%';
 
 $DEBUG = 0;
 
+$conf_cache_enabled = 0;
+
 =head1 NAME
 
 FS::Conf - Freeside configuration values
@@ -123,7 +125,8 @@ sub _config {
   my($self,$name,$agentnum,$agentonly)=@_;
   my $hashref = { 'name' => $name };
   local $FS::Record::conf = undef;  # XXX evil hack prevents recursion
-  $conf_cache = undef unless $conf_cache_enabled;  # use cache only when it is safe to do so
+  $conf_cache = undef unless $conf_cache_enabled; # use cache only when it is
+                                                  # safe to do so
   my $cv;
   my @a = (
     ($agentnum || ()),
@@ -140,7 +143,8 @@ sub _config {
       my $key = join(':',$name, $a, $l);
       if (! exists $conf_cache->{$key}){
         $hashref->{locale} = $l;
-        # $conf_cache is reset in FS::UID during myconnect, so the cache is reset per connection
+        # $conf_cache is reset in FS::UID during myconnect, so the cache is
+        # reset per connection
         $conf_cache->{$key} = FS::Record::qsearchs('conf', $hashref);
       }
       return $conf_cache->{$key} if $conf_cache->{$key};

commit 688288d7c60a648519d3b0127cd9286401078204
Author: Jason Terry <jterry at bluehost.com>
Date:   Tue Feb 17 09:50:56 2015 -0700

    Disable conf_cache by default, enable it only when safe to do so
    
    Conflicts:
    	FS/FS/Conf.pm

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 855c9f4..e204747 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -1,7 +1,9 @@
 package FS::Conf;
 
 use strict;
-use vars qw($base_dir @config_items @base_items @card_types $DEBUG $conf_cache);
+use vars qw( $base_dir @config_items @base_items @card_types $DEBUG
+             $conf_cache $conf_cache_enabled
+           );
 use Carp;
 use IO::File;
 use File::Basename;
@@ -121,6 +123,7 @@ sub _config {
   my($self,$name,$agentnum,$agentonly)=@_;
   my $hashref = { 'name' => $name };
   local $FS::Record::conf = undef;  # XXX evil hack prevents recursion
+  $conf_cache = undef unless $conf_cache_enabled;  # use cache only when it is safe to do so
   my $cv;
   my @a = (
     ($agentnum || ()),
diff --git a/htetc/handler.pl b/htetc/handler.pl
index 3c68e83..18108ab 100644
--- a/htetc/handler.pl
+++ b/htetc/handler.pl
@@ -6,6 +6,9 @@ use strict;
 use warnings;
 use FS::Mason qw( mason_interps );
 use FS::Trace;
+use FS::Conf;
+
+$FS::Conf::conf_cache_enabled = 1; # enable FS::Conf caching for performance
 
 if ( %%%RT_ENABLED%%% ) {
 

commit 24bdd2d7ec485534761891bd1b0c42f14c11435a
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue Feb 24 18:53:32 2015 -0800

    reverting accidentally committed local changes

diff --git a/FS/FS/Daemon/Preforking.pm b/FS/FS/Daemon/Preforking.pm
index 4c382eb..4f3f2be 100644
--- a/FS/FS/Daemon/Preforking.pm
+++ b/FS/FS/Daemon/Preforking.pm
@@ -46,7 +46,7 @@ use warnings;
 use strict;
 
 use constant DEBUG         => 0;       # Enable much runtime information.
-use constant MAX_PROCESSES => 4;      # Total server process count. XXX conf to increase per-different daemon for busy sites using this (currently the only things using this are freeside-xmlrpcd and freeside-selfservice-xmlrpcd)
+use constant MAX_PROCESSES => 10;      # Total server process count. XXX conf to increase per-different daemon for busy sites using this (currently the only things using this are freeside-xmlrpcd and freeside-selfservice-xmlrpcd)
 #use constant TESTING_CHURN => 0;       # Randomly test process respawning.
 
 use vars qw( @EXPORT_OK $FREESIDE_LOG $SERVER_PORT $user $handle_request );
diff --git a/FS/bin/freeside-queued b/FS/bin/freeside-queued
index 4786132..7c4cf1b 100644
--- a/FS/bin/freeside-queued
+++ b/FS/bin/freeside-queued
@@ -38,16 +38,15 @@ drop_root();
 $ENV{HOME} = (getpwuid($>))[7]; #for ssh
 
 warn "connecting to database\n" if $DEBUG;
-#$@ = 'not connected';
-#while ( $@ ) {
-#  eval { adminsuidsetup $user; };
-#  if ( $@ ) {
-#    warn $@;
-#    warn "sleeping for reconnect...\n";
-#    sleep 5;
-#  }
-#}
-adminsuidsetup $user;
+$@ = 'not connected';
+while ( $@ ) {
+  eval { adminsuidsetup $user; };
+  if ( $@ ) {
+    warn $@;
+    warn "sleeping for reconnect...\n";
+    sleep 5;
+  }
+}
 
 my $log = FS::Log->new('queue');
 logfile( "%%%FREESIDE_LOG%%%/queuelog.". $FS::UID::datasrc );

commit ae02d1178c6859f7a0a5e4a22c685de5f0477568
Author: Jason Terry <jterry at bluehost.com>
Date:   Wed Feb 11 15:32:08 2015 -0700

    Cache the FS::Conf info per page load, for performance.
    
    Conflicts:
    	FS/FS/Conf.pm

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index c4e5af4..855c9f4 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -1,7 +1,7 @@
 package FS::Conf;
 
-use vars qw($base_dir @config_items @base_items @card_types $DEBUG);
 use strict;
+use vars qw($base_dir @config_items @base_items @card_types $DEBUG $conf_cache);
 use Carp;
 use IO::File;
 use File::Basename;
@@ -134,9 +134,13 @@ sub _config {
   foreach my $a (@a) {
     $hashref->{agentnum} = $a;
     foreach my $l (@l) {
-      $hashref->{locale} = $l;
-      $cv = FS::Record::qsearchs('conf', $hashref);
-      return $cv if $cv;
+      my $key = join(':',$name, $a, $l);
+      if (! exists $conf_cache->{$key}){
+        $hashref->{locale} = $l;
+        # $conf_cache is reset in FS::UID during myconnect, so the cache is reset per connection
+        $conf_cache->{$key} = FS::Record::qsearchs('conf', $hashref);
+      }
+      return $conf_cache->{$key} if $conf_cache->{$key};
     }
   }
   return undef;
@@ -362,6 +366,12 @@ sub set {
     $error = $new->insert;
   }
 
+  if (! $error) {
+    # clean the object cache
+    my $key = join(':',$name, $agentnum, $self->{locale});
+    $conf_cache->{ $key } = $new;
+  }
+
   die "error setting configuration value: $error \n"
     if $error;
 
diff --git a/FS/FS/Daemon/Preforking.pm b/FS/FS/Daemon/Preforking.pm
index f3a39a6..4c382eb 100644
--- a/FS/FS/Daemon/Preforking.pm
+++ b/FS/FS/Daemon/Preforking.pm
@@ -46,7 +46,7 @@ use warnings;
 use strict;
 
 use constant DEBUG         => 0;       # Enable much runtime information.
-use constant MAX_PROCESSES => 10;      # Total server process count.
+use constant MAX_PROCESSES => 4;      # Total server process count. XXX conf to increase per-different daemon for busy sites using this (currently the only things using this are freeside-xmlrpcd and freeside-selfservice-xmlrpcd)
 #use constant TESTING_CHURN => 0;       # Randomly test process respawning.
 
 use vars qw( @EXPORT_OK $FREESIDE_LOG $SERVER_PORT $user $handle_request );
diff --git a/FS/FS/UID.pm b/FS/FS/UID.pm
index f41735d..4535799 100644
--- a/FS/FS/UID.pm
+++ b/FS/FS/UID.pm
@@ -176,6 +176,9 @@ sub myconnect {
                            )
     or die "DBI->connect error: $DBI::errstr\n";
 
+  require FS::Conf;
+  $FS::Conf::conf_cache = undef;
+
   if ( $schema ) {
     use DBIx::DBSchema::_util qw(_load_driver ); #quelle hack
     my $driver = _load_driver($handle);
diff --git a/FS/bin/freeside-queued b/FS/bin/freeside-queued
index 7c4cf1b..4786132 100644
--- a/FS/bin/freeside-queued
+++ b/FS/bin/freeside-queued
@@ -38,15 +38,16 @@ drop_root();
 $ENV{HOME} = (getpwuid($>))[7]; #for ssh
 
 warn "connecting to database\n" if $DEBUG;
-$@ = 'not connected';
-while ( $@ ) {
-  eval { adminsuidsetup $user; };
-  if ( $@ ) {
-    warn $@;
-    warn "sleeping for reconnect...\n";
-    sleep 5;
-  }
-}
+#$@ = 'not connected';
+#while ( $@ ) {
+#  eval { adminsuidsetup $user; };
+#  if ( $@ ) {
+#    warn $@;
+#    warn "sleeping for reconnect...\n";
+#    sleep 5;
+#  }
+#}
+adminsuidsetup $user;
 
 my $log = FS::Log->new('queue');
 logfile( "%%%FREESIDE_LOG%%%/queuelog.". $FS::UID::datasrc );

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

Summary of changes:
 FS/FS/Conf.pm              |   25 +++++++++++++++++++++----
 FS/FS/Daemon/Preforking.pm |    2 +-
 FS/FS/UID.pm               |    3 +++
 htetc/handler.pl           |    3 +++
 4 files changed, 28 insertions(+), 5 deletions(-)




More information about the freeside-commits mailing list