Merge branch 'master' of ssh://git.indexdata.com/home/git/pub/yaz
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 15 Jun 2015 13:00:15 +0000 (15:00 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 15 Jun 2015 13:00:15 +0000 (15:00 +0200)
src/zoom-c.c
src/zoom-p.h
src/zoom-sru.c
src/zoom-z3950.c

index 53cbb10..b6cc643 100644 (file)
@@ -49,7 +49,6 @@ static void initlog(void)
     }
 }
 
-void ZOOM_connection_remove_tasks(ZOOM_connection c);
 static zoom_ret send_HTTP_redirect(ZOOM_connection c, const char *uri);
 
 void ZOOM_set_dset_error(ZOOM_connection c, int error,
@@ -84,7 +83,6 @@ void ZOOM_set_dset_error(ZOOM_connection c, int error,
                 c, c->host_port ? c->host_port : "<>", dset, error,
                 addinfo ? addinfo : "",
                 addinfo2 ? addinfo2 : "");
-        ZOOM_connection_remove_tasks(c);
     }
 }
 
@@ -189,6 +187,8 @@ void ZOOM_connection_remove_task(ZOOM_connection c)
     if (task)
     {
         c->tasks = task->next;
+        yaz_log(YLOG_LOG, "remove task p=%d type=%d next=%p",
+                task, (int) task->which, c->tasks);
         switch (task->which)
         {
         case ZOOM_TASK_SEARCH:
index 236313b..79f2f44 100644 (file)
@@ -247,6 +247,7 @@ zoom_ret ZOOM_connection_Z3950_send_init(ZOOM_connection c);
 
 ZOOM_task ZOOM_connection_add_task(ZOOM_connection c, int which);
 void ZOOM_connection_remove_task(ZOOM_connection c);
+void ZOOM_connection_remove_tasks(ZOOM_connection c);
 int ZOOM_test_reconnect(ZOOM_connection c);
 
 ZOOM_record ZOOM_record_cache_lookup(ZOOM_resultset r, int pos,
index 17f7c18..bf89a44 100644 (file)
@@ -391,14 +391,14 @@ static zoom_ret handle_srw_response(ZOOM_connection c,
 #endif
 
 #if YAZ_HAVE_XML2
-static void handle_srw_scan_response(ZOOM_connection c,
-                                     Z_SRW_scanResponse *res)
+static zoom_ret handle_srw_scan_response(ZOOM_connection c,
+                                         Z_SRW_scanResponse *res)
 {
     NMEM nmem = odr_extract_mem(c->odr_in);
     ZOOM_scanset scan;
 
     if (!c->tasks || c->tasks->which != ZOOM_TASK_SCAN)
-        return;
+        return zoom_complete;
     scan = c->tasks->u.scan.scan;
 
     if (res->num_diagnostics > 0)
@@ -410,6 +410,7 @@ static void handle_srw_scan_response(ZOOM_connection c,
 
     ZOOM_options_set_int(scan->options, "number", res->num_terms);
     nmem_destroy(nmem);
+    return zoom_complete;
 }
 #endif
 
@@ -434,7 +435,7 @@ int ZOOM_handle_sru(ZOOM_connection c, Z_HTTP_Response *hres,
             if (sr->which == Z_SRW_searchRetrieve_response)
                 *cret = handle_srw_response(c, sr->u.response);
             else if (sr->which == Z_SRW_scan_response)
-                handle_srw_scan_response(c, sr->u.scan_response);
+                *cret = handle_srw_scan_response(c, sr->u.scan_response);
         }
     }
     else
@@ -460,7 +461,7 @@ int ZOOM_handle_sru(ZOOM_connection c, Z_HTTP_Response *hres,
             if (sr->which == Z_SRW_searchRetrieve_response)
                 *cret = handle_srw_response(c, sr->u.response);
             else if (sr->which == Z_SRW_scan_response)
-                handle_srw_scan_response(c, sr->u.scan_response);
+                *cret = handle_srw_scan_response(c, sr->u.scan_response);
             else
                 ret = -1;
         }
index 701f5a4..9c810e8 100644 (file)
@@ -1309,7 +1309,10 @@ static void handle_Z3950_search_response(ZOOM_connection c,
 static void handle_Z3950_sort_response(ZOOM_connection c, Z_SortResponse *res)
 {
     if (res->diagnostics && res->num_diagnostics > 0)
+    {
         response_diag(c, res->diagnostics[0]);
+        ZOOM_connection_remove_tasks(c);
+    }
 }
 
 static void handle_Z3950_scan_response(ZOOM_connection c, Z_ScanResponse *res)
@@ -1356,13 +1359,17 @@ static void handle_Z3950_records(ZOOM_connection c, Z_Records *sr,
     schema =  c->tasks->u.search.schema;
 
     if (sr && sr->which == Z_Records_NSD)
+    {
         response_default_diag(c, sr->u.nonSurrogateDiagnostic);
+        ZOOM_connection_remove_tasks(c);
+    }
     else if (sr && sr->which == Z_Records_multipleNSD)
     {
         if (sr->u.multipleNonSurDiagnostics->num_diagRecs >= 1)
             response_diag(c, sr->u.multipleNonSurDiagnostics->diagRecs[0]);
         else
             ZOOM_set_error(c, ZOOM_ERROR_DECODE, 0);
+        ZOOM_connection_remove_tasks(c);
     }
     else
     {