From dc8b8c82885078192757451a0326de409726bcbc Mon Sep 17 00:00:00 2001
From: erickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Tue, 20 Jul 2010 21:16:00 +0000
Subject: [PATCH] login just before starting work and log out after each
 request is handled.  this is removes the need to check for bad authtokens and
 re-login mid-process

git-svn-id: svn://svn.open-ils.org/ILS/trunk@16992 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
 Open-ILS/src/support-scripts/marc_stream_importer.pl | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/Open-ILS/src/support-scripts/marc_stream_importer.pl b/Open-ILS/src/support-scripts/marc_stream_importer.pl
index f04b82407c..07350e4e87 100755
--- a/Open-ILS/src/support-scripts/marc_stream_importer.pl
+++ b/Open-ILS/src/support-scripts/marc_stream_importer.pl
@@ -373,6 +373,8 @@ sub process_request {   # The core Net::Server method
 
     my ($imported, $failed) = (0, 0);
 
+    new_auth_token(); # login
+
     if ($real_opts->{noqueue}) {
         ($imported, $failed) = old_process_batch_data($data);
     } else {
@@ -391,6 +393,8 @@ sub process_request {   # The core Net::Server method
     $msg .= "Failed to import $failed records\n" if $failed;
     $msg .= "\x00";
     print $client $msg;
+
+    clear_auth_token(); # logout
 }
 
 
@@ -402,10 +406,17 @@ sub new_auth_token {
     return $authtoken;
 }
 
+sub clear_auth_token {
+    $apputils->simplereq(
+        'open-ils.auth',
+        'open-ils.auth.session.delete',
+        $authtoken
+    );
+}
+
 ##### MAIN ######
 
 osrf_connect($osrf_config);
-new_auth_token();
 print "Calling Net::Server run ", (@ARGV ? "with command-line options: " . join(' ', @ARGV) : ''), "\n";
 __PACKAGE__->run(conf_file => $conf_file);
 
-- 
2.11.0