Updates to pz:authentication documentation
[pazpar2-moved-to-github.git] / src / client.c
index 5db3018..fe5bef3 100644 (file)
@@ -90,7 +90,7 @@ static int client_use(int delta)
     return clients;
 }
 
-int clients_count(void)
+int clients_get_count(void)
 {
     return client_use(0);
 }
@@ -825,6 +825,7 @@ int client_fetch_more(struct client *cl)
     const char *str;
     int extend_recs = 0;
     int number = cl->hits - cl->record_offset;
+    struct connection *co = client_get_connection(cl);
 
     str = session_setting_oneval(sdb, PZ_EXTENDRECS);
     if (!str || !*str)
@@ -840,10 +841,13 @@ int client_fetch_more(struct client *cl)
 
     if (number > extend_recs)
         number = extend_recs;
-    if (number > 0)
+    if (number <= 0)
+        yaz_log(YLOG_LOG, "cl=%s. OK no more in total set", client_get_id(cl));
+    else if (!co)
+        yaz_log(YLOG_LOG, "cl=%s. No connection", client_get_id(cl));
+    else
     {
         ZOOM_resultset set = cl->resultset;
-        struct connection *co = client_get_connection(cl);
 
         str = session_setting_oneval(sdb, PZ_REQUESTSYNTAX);
         ZOOM_resultset_option_set(set, "preferredRecordSyntax", str);
@@ -856,10 +860,6 @@ int client_fetch_more(struct client *cl)
         connection_continue(co);
         return 1;
     }
-    else
-    {
-        yaz_log(YLOG_LOG, "cl=%s. OK no more in total set", client_get_id(cl));
-    }
     return 0;
 }
 
@@ -958,9 +958,10 @@ int client_start_search(struct client *cl)
     }
     else if (!rc_prep_connection)
     {
-        session_log(se, YLOG_LOG, "%s: postponing search: No connection",
-                    client_get_id(cl));
-        client_set_state_nb(cl, Client_Working);
+        client_set_diagnostic(cl, 2,
+                              ZOOM_diag_str(2),
+                              "Cannot create connection");
+        client_set_state_nb(cl, Client_Error);
         return -1;
     }
     co = client_get_connection(cl);
@@ -1171,6 +1172,12 @@ void client_disconnect(struct client *cl)
     client_set_connection(cl, 0);
 }
 
+void client_mark_dead(struct client *cl)
+{
+    if (cl->connection)
+        connection_mark_dead(cl->connection);
+}
+
 void client_stop(struct client *cl)
 {
     client_lock(cl);