Clean up OpenSRF::AppSession objects after use
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Fri, 29 Jul 2011 18:08:28 +0000 (14:08 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Fri, 29 Jul 2011 18:08:28 +0000 (14:08 -0400)
These things need ->kill_me called on them after we're done using them.

(note to self: check to see if we can just add a DESTROY sub to that
package)

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm

index c0d8e64..fbdd904 100644 (file)
@@ -225,15 +225,15 @@ sub fetch_user_holds {
 
     my $e = $self->editor;
 
-    my $circ = OpenSRF::AppSession->create('open-ils.circ');
-
     if(!$hold_ids) {
+        my $circ = OpenSRF::AppSession->create('open-ils.circ');
 
         $hold_ids = $circ->request(
             'open-ils.circ.holds.id_list.retrieve.authoritative', 
             $e->authtoken, 
             $e->requestor->id
         )->gather(1);
+        $circ->kill_me;
     
         $hold_ids = [ grep { defined $_ } @$hold_ids[$offset..($offset + $limit - 1)] ] if $limit or $offset;
     }
@@ -476,7 +476,7 @@ sub load_place_hold {
                 $ctx->{hold_failed} = 1;
                 $ctx->{hold_failed_event} = $usr;
             }
-            # XXX Does $actor need to be explicity disconnected/destroyed?
+            $actor->kill_me;
         }
 
         my $args = {
@@ -611,8 +611,6 @@ sub fetch_user_circs {
 
     return [] unless @circ_ids;
 
-    my $cstore = OpenSRF::AppSession->create('open-ils.cstore');
-
     my $qflesh = {
         flesh => 3,
         flesh_fields => {
@@ -980,6 +978,8 @@ sub prepare_fines {
         );
     }
 
+    $cstore->kill_me;
+
     $self->ctx->{"fines"}->{$_} /= 100.0 for (@total_keys);
     return;
 }
index f7a86b5..5ec5db9 100644 (file)
@@ -24,9 +24,11 @@ sub load_record {
 
     # run copy retrieval in parallel to bib retrieval
     # XXX unapi
-    my $copy_rec = OpenSRF::AppSession->create('open-ils.cstore')->request(
+    my $cstore = OpenSRF::AppSession->create('open-ils.cstore');
+    my $copy_rec = $cstore->request(
         'open-ils.cstore.json_query.atomic', 
-        $self->mk_copy_query($rec_id, $org, $depth, $copy_limit, $copy_offset));
+        $self->mk_copy_query($rec_id, $org, $depth, $copy_limit, $copy_offset)
+    );
 
     my (undef, @rec_data) = $self->get_records_and_facets([$rec_id], undef, {flesh => '{holdings_xml,mra}'});
     $ctx->{bre_id} = $rec_data[0]->{id};
@@ -39,6 +41,8 @@ sub load_record {
     $ctx->{have_holdings_to_show} = 0;
     $self->get_hold_copy_summary($rec_id, $org);
 
+    $cstore->kill_me;
+
     # XXX TODO we'll also need conditional logic to show MFHD-based holdings
     if (
         $ctx->{get_org_setting}->
@@ -173,12 +177,14 @@ sub mk_marc_html {
 sub get_holding_summaries {
     my ($self, $rec_id, $org, $depth) = @_;
 
-    return (
-        create OpenSRF::AppSession("open-ils.serial")->request(
-            "open-ils.serial.bib.summary_statements",
-            $rec_id, {"org_id" => $org, "depth" => $depth}
-        )->gather(1)
-    );
+    my $serial = create OpenSRF::AppSession("open-ils.serial");
+    my $result = $serial->request(
+        "open-ils.serial.bib.summary_statements",
+        $rec_id, {"org_id" => $org, "depth" => $depth}
+    )->gather(1);
+
+    $serial->kill_me;
+    return $result;
 }
 
 sub get_expanded_holdings {
@@ -188,7 +194,8 @@ sub get_expanded_holdings {
     my $holding_offset = int($self->cgi->param("holding_offset") || 0);
     my $type = $self->cgi->param("expand_holding_type");
 
-    return create OpenSRF::AppSession("open-ils.serial")->request(
+    my $serial =  create OpenSRF::AppSession("open-ils.serial");
+    my $result = $serial->request(
         "open-ils.serial.received_siss.retrieve.by_bib.atomic",
         $rec_id, {
             "ou" => $org, "depth" => $depth,
@@ -196,6 +203,9 @@ sub get_expanded_holdings {
             "type" => $type
         }
     )->gather(1);
+
+    $serial->kill_me;
+    return $result;
 }
 
 sub any_call_number_label {
@@ -223,6 +233,8 @@ sub prepare_browse_call_numbers {
         $cn, $org_unit->shortname, 9, $self->cgi->param("cnoffset")
     )->gather(1) || [];
 
+    $supercat->kill_me;
+
     $self->ctx->{browsed_call_numbers} = [
         map {
             $_->record->marc(
@@ -237,13 +249,16 @@ sub prepare_browse_call_numbers {
 sub get_hold_copy_summary {
     my ($self, $rec_id, $org) = @_;
     
-    my $req1 = OpenSRF::AppSession->create('open-ils.search')->request(
+    my $search = OpenSRF::AppSession->create('open-ils.search');
+    my $req1 = $search->request(
         'open-ils.search.biblio.record.copy_count', $org, $rec_id); 
 
     $self->ctx->{record_hold_count} = $U->simplereq(
         'open-ils.circ', 'open-ils.circ.bre.holds.count', $rec_id);
 
     $self->ctx->{copy_summary} = $req1->recv->content;
+
+    $search->kill_me;
 }
 
 1;
index 96f150e..6397d84 100644 (file)
@@ -237,6 +237,7 @@ sub item_barcode_shortcut {
         my $rec_ids = $search->request(
             $method, $self->cgi->param("query")
         )->gather(1);
+        $search->kill_me;
 
         if (ref $rec_ids ne 'ARRAY') {
 
@@ -304,6 +305,7 @@ sub marc_expert_search {
                 "searches" => $query, "org_unit" => $org_unit
             }, $limit, $offset
         )->gather(1);
+        $search->kill_me;
 
         if (defined $U->event_code($results)) {
             $self->apache->log->warn(
index 1245605..3ab34ff 100644 (file)
@@ -212,6 +212,8 @@ sub get_records_and_facets {
         $facets = undef;
     }
 
+    $search->kill_me;
+
     return ($facets, @data);
 }