Bug fix: shell might terminate even though new request was initiated
[egate.git] / www / z39util.tcl
index 23fabd6..fcd6bdb 100644 (file)
@@ -1,5 +1,5 @@
 #
-# $Id: z39util.tcl,v 1.10 1995/11/14 09:53:16 adam Exp $
+# $Id: z39util.tcl,v 1.12 1995/12/20 16:31:34 adam Exp $
 #
 proc saveState {} {
     uplevel #0 {
@@ -118,7 +118,7 @@ proc display-raw {zset no tno} {
         set indicator [lindex $line 1]
         set fields [lindex $line 2]
         set l [string length $indicator]
-        html "$tag "
+        html "<tt>$tag "
         if {$l > 0} {
             for {set i 0} {$i < $l} {incr i} {
                 if {[string index $indicator $i] == " "} {
@@ -128,6 +128,7 @@ proc display-raw {zset no tno} {
                 }
             }
         }
+        html "</tt>"
         foreach field $fields {
             set id [lindex $field 0]
             set data [lindex $field 1]
@@ -155,7 +156,7 @@ proc put-marc-contents {cc} {
     }
     html $cc
     if {$ref != ""} {
-        html {">} $urltype { reference</a>}
+        html {">} $cc {</a>}
     }
 }
 
@@ -412,7 +413,11 @@ proc z39search {setNo piggy tno elements} {
             displayError "Cannot connect to target" $host
             return 0
         } elseif {$sessionWait == 0} {
-            zwait sessionWait
+            if {[catch {zwait sessionWait 300}]} {
+               $zz disconnect
+                displayError "Cannot connect to target" $host
+                return 0
+            }
             if {$sessionWait != 1} {
                 displayError "Cannot connect to target" $host
                 return 0
@@ -422,6 +427,7 @@ proc z39search {setNo piggy tno elements} {
         set sessionWait 0
         if {[catch {$zz init}]} {
             displayError "Cannot initialize target" $host
+           $zz disconnect
             return 0
         }
         if {[catch {zwait sessionWait 60}]} {
@@ -454,6 +460,7 @@ proc z39search {setNo piggy tno elements} {
     $zz.$setNo mediumSetElementSetNames $elements
     $zz.$setNo recordElements $elements
 
+    wlog debug "database=$database"
     eval $zz.$setNo databaseNames $database
 
     $zz.$setNo preferredRecordSyntax USMARC
@@ -472,27 +479,20 @@ proc z39search {setNo piggy tno elements} {
     $zz.$setNo search $query
 
     if {[catch {zwait sessionWait 600}]} {
-        wlog debug "timeout/cancel in present"
+        wlog debug "timeout/cancel in search"
         displayError "Timeout in search" {}
         html "</body></html>\n"
         $zz disconnect
         return 0
     }
         
-    if {$sessionWait != 1} {
+    if {$sessionWait == -1} {
         displayError "Search fail" "Connection closed"
         html "</body></html>\n"
         $zz disconnect
-        return 0
     }
-    set status [$zz.$setNo responseStatus]
-    if {[lindex $status 0] == "NSD"} {
-        set code [lindex $status 1]
-        set msg [lindex $status 2]
-        set addinfo [lindex $status 3]
-        displayError "Diagnostic message" \
-                "$msg: $addinfo\n<br>(error code $code)"
-        return 0
+    if {$sessionWait != 1} {
+       return 0
     }
     set hist($setNo,hits) [$zz.$setNo resultCount]
     return 1
@@ -731,3 +731,5 @@ proc displayError {msga msgb} {
     }
     html "</center><p>\n"
 }
+
+set useIcons 1
\ No newline at end of file