Release record block on show after first chunk
[pazpar2-moved-to-github.git] / src / connection.c
index 3fb061b..1525dfb 100644 (file)
@@ -159,6 +159,7 @@ static struct connection *connection_create(struct client *cl,
 
 static void non_block_events(struct connection *co)
 {
+    int got_records = 0;
     IOCHAN iochan = co->iochan;
     ZOOM_connection link = co->link;
     while (1)
@@ -213,6 +214,7 @@ static void non_block_events(struct connection *co)
             break;
         case ZOOM_EVENT_RECV_RECORD:
             client_record_response(cl);
+            got_records = 1;
             break;
         default:
             yaz_log(YLOG_LOG, "Unhandled event (%d) from %s",
@@ -220,6 +222,16 @@ static void non_block_events(struct connection *co)
         }
         client_destroy(cl);
     }
+    if (got_records)
+    {
+        struct client *cl = co->client;
+        if (cl)
+        {
+            client_incref(cl); 
+            client_got_records(cl);
+            client_destroy(cl);
+        }
+    }
 }
 
 void connection_continue(struct connection *co)