Moved prototype of ZOOM_connection_remove_tasks further to the "top" of
[yaz-moved-to-github.git] / src / zoom-c.c
index 5308769..cb16f92 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: zoom-c.c,v 1.110 2007-01-23 19:25:21 adam Exp $
+ * $Id: zoom-c.c,v 1.113 2007-02-21 09:19:26 adam Exp $
  */
 /**
  * \file zoom-c.c
@@ -27,6 +27,8 @@
 #include <yaz/cql.h>
 #include <yaz/ccl.h>
 
+#define TASK_FIX 1
+
 static int log_api = 0;
 static int log_details = 0;
 
@@ -39,6 +41,21 @@ static zoom_ret ZOOM_connection_send_init(ZOOM_connection c);
 static zoom_ret do_write_ex(ZOOM_connection c, char *buf_out, int len_out);
 static char *cql2pqf(ZOOM_connection c, const char *cql);
 
+
+/*
+ * This wrapper is just for logging failed lookups.  It would be nicer
+ * if it could cause failure when a lookup fails, but that's hard.
+ */
+static Odr_oid *zoom_yaz_str_to_z3950oid(ZOOM_connection c,
+                                         int oid_class, const char *str) {
+    Odr_oid *res = yaz_str_to_z3950oid(c->odr_out, oid_class, str);
+    if (res == 0)
+        yaz_log(YLOG_WARN, "%p OID lookup (%d, '%s') failed",
+                c, (int) oid_class, str);
+    return res;
+}
+
+
 static void initlog(void)
 {
     static int log_level_initialized = 0;
@@ -110,6 +127,8 @@ ZOOM_API(int) ZOOM_connection_peek_event(ZOOM_connection c)
     return event ? event->kind : ZOOM_EVENT_NONE;
 }
 
+void ZOOM_connection_remove_tasks(ZOOM_connection c);
+
 static void set_dset_error(ZOOM_connection c, int error,
                            const char *dset,
                            const char *addinfo, const char *addinfo2)
@@ -135,11 +154,16 @@ static void set_dset_error(ZOOM_connection c, int error,
     }
     else if (addinfo)
         c->addinfo = xstrdup(addinfo);
-    if (error)
+    if (error != ZOOM_ERROR_NONE)
+    {
         yaz_log(log_api, "%p set_dset_error %s %s:%d %s %s",
                 c, c->host_port ? c->host_port : "<>", dset, error,
                 addinfo ? addinfo : "",
                 addinfo2 ? addinfo2 : "");
+#if TASK_FIX
+        ZOOM_connection_remove_tasks(c);
+#endif
+    }
 }
 
 #if YAZ_HAVE_XML2
@@ -150,6 +174,7 @@ static void set_HTTP_error(ZOOM_connection c, int error,
 }
 #endif
 
+
 static void set_ZOOM_error(ZOOM_connection c, int error,
                            const char *addinfo)
 {
@@ -1250,7 +1275,7 @@ static zoom_ret ZOOM_connection_send_init(ZOOM_connection c)
                     odr_prepend(c->odr_out, "ZOOM-C",
                                 ireq->implementationName));
     
-    version = odr_strdup(c->odr_out, "$Revision: 1.110 $");
+    version = odr_strdup(c->odr_out, "$Revision: 1.113 $");
     if (strlen(version) > 10)   /* check for unexpanded CVS strings */
         version[strlen(version)-2] = '\0';
     ireq->implementationVersion = 
@@ -1552,7 +1577,7 @@ static zoom_ret ZOOM_connection_send_search(ZOOM_connection c)
     }
     if (syntax)
         search_req->preferredRecordSyntax =
-            yaz_str_to_z3950oid(c->odr_out, CLASS_RECSYN, syntax);
+            zoom_yaz_str_to_z3950oid(c, CLASS_RECSYN, syntax);
     
     if (!r->setname)
     {
@@ -2547,7 +2572,7 @@ static zoom_ret send_present(ZOOM_connection c)
 
     if (syntax && *syntax)
         req->preferredRecordSyntax =
-            yaz_str_to_z3950oid(c->odr_out, CLASS_RECSYN, syntax);
+            zoom_yaz_str_to_z3950oid(c, CLASS_RECSYN, syntax);
 
     if (resultset->schema && *resultset->schema)
     {
@@ -2567,14 +2592,14 @@ static zoom_ret send_present(ZOOM_connection c)
 
         compo->u.complex->generic->which = Z_Schema_oid;
         compo->u.complex->generic->schema.oid = (Odr_oid *)
-            yaz_str_to_z3950oid (c->odr_out, CLASS_SCHEMA, resultset->schema);
+            zoom_yaz_str_to_z3950oid (c, CLASS_SCHEMA, resultset->schema);
 
         if (!compo->u.complex->generic->schema.oid)
         {
             /* OID wasn't a schema! Try record syntax instead. */
 
             compo->u.complex->generic->schema.oid = (Odr_oid *)
-                yaz_str_to_z3950oid (c->odr_out, CLASS_RECSYN, resultset->schema);
+                zoom_yaz_str_to_z3950oid (c, CLASS_RECSYN, resultset->schema);
         }
         if (elementSetName && *elementSetName)
         {