doing some manual memory cleanup for circ references
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 17 Jul 2006 16:47:23 +0000 (16:47 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 17 Jul 2006 16:47:23 +0000 (16:47 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5041 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Circ/ScriptBuilder.pm
Open-ILS/src/perlmods/OpenILS/Utils/PermitHold.pm

index 836e409..33a9983 100644 (file)
@@ -5,6 +5,7 @@ use OpenILS::Utils::CStoreEditor qw/:funcs/;
 use OpenILS::Application::AppUtils;
 use OpenILS::Application::Actor;
 use OpenSRF::Utils::Logger qw/$logger/;
+use Scalar::Util;
 my $U = "OpenILS::Application::AppUtils";
 use Data::Dumper;
 
@@ -17,6 +18,7 @@ my $ORG_TREE;
 my @ORG_LIST;
 
 
+
 # -----------------------------------------------------------------------
 # Possible Args:
 #  copy
@@ -65,7 +67,9 @@ sub build_runner {
 
        my $runner = OpenILS::Utils::ScriptRunner->new;
 
-       $runner->insert( "$evt.groupTree",      $GROUP_TREE, 1);
+       my $gt = $GROUP_TREE;
+       weaken($gt); # just to be safe
+       $runner->insert( "$evt.groupTree",      $gt, 1);
 
 
        $runner->insert( "$evt.patron",         $ctx->{patron}, 1);
@@ -269,13 +273,16 @@ sub insert_org_methods {
                flatten_org_tree($ORG_TREE);
        }
 
+       my $r = $runner;
+       weaken($r);
+
        $runner->insert(__OILS_FUNC_isOrgDescendent  => 
                sub {
                        my( $write_key, $sname, $id ) = @_;
                        my ($parent)    = grep { $_->shortname eq $sname } @ORG_LIST;
                        my ($child)             = grep { $_->id == $id } @ORG_LIST;
                        my $val = is_org_descendent( $parent, $child );
-                       $runner->insert($write_key, $val);
+                       $r->insert($write_key, $val);
                        return $val;
                }
        );
index 94e486e..871cdf5 100644 (file)
@@ -18,9 +18,7 @@ my $script_libs;      # - extra script libs
 # params within a hash are: copy, patron, 
 # requestor, request_lib, title, title_descriptor
 sub permit_copy_hold {
-
        my $params      = shift;
-       my $k                   = 'environment';
 
        my $runner = OpenILS::Application::Circ::ScriptBuilder->build(
                {
@@ -40,6 +38,8 @@ sub permit_copy_hold {
        load_scripts($runner);
        my $result = $runner->run or throw OpenSRF::EX::ERROR ("Hold Copy Permit Script Died: $@");
 
+       $runner->context->destroy;
+
        # --------------------------------------------------------------
        # Extract and uniquify the event list
        # --------------------------------------------------------------