Fix case for http:close and SRU step (bug #3484)
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 17 Jun 2010 13:39:58 +0000 (15:39 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 17 Jun 2010 13:39:58 +0000 (15:39 +0200)
Fix case where servers responds with Connection:close and ensure
that if there is a current task it is resumed (like fetching
more records in a result set).

src/zoom-c.c

index a2a0235..dd1698c 100644 (file)
@@ -4350,18 +4350,34 @@ static void handle_http(ZOOM_connection c, Z_HTTP_Response *hres)
         do_close(c);
     }
     if (cret == zoom_complete)
-        ZOOM_connection_remove_task(c);
-    if (!strcmp(hres->version, "1.0"))
     {
-        /* HTTP 1.0: only if Keep-Alive we stay alive.. */
-        if (!connection_head || strcmp(connection_head, "Keep-Alive"))
-            do_close(c);
+        yaz_log(YLOG_LOG, "removing tasks in handle_http");
+        ZOOM_connection_remove_task(c);
     }
-    else 
     {
-        /* HTTP 1.1: only if no close we stay alive .. */
-        if (connection_head && !strcmp(connection_head, "close"))
+        int must_close = 0;
+        if (!strcmp(hres->version, "1.0"))
+        {
+            /* HTTP 1.0: only if Keep-Alive we stay alive.. */
+            if (!connection_head || strcmp(connection_head, "Keep-Alive"))
+                must_close = 1;
+        }
+        else
+        {
+            /* HTTP 1.1: only if no close we stay alive.. */
+            if (connection_head && !strcmp(connection_head, "close"))
+                must_close = 1;
+        }
+        if (must_close)
+        {
             do_close(c);
+            if (c->tasks)
+            {
+                c->tasks->running = 0;
+                ZOOM_connection_insert_task(c, ZOOM_TASK_CONNECT);
+                c->reconnect_ok = 0;
+            }
+        }
     }
 }
 #endif