Allow user-defined info for target suffix.
[pazpar2-moved-to-github.git] / src / client.c
index bb5ee3a..aba43f0 100644 (file)
@@ -147,7 +147,9 @@ void client_set_state(struct client *cl, enum client_state st)
        that session is not mutex locked if client is already active */
     if (was_active && !client_is_active(cl) && cl->session)
     {
+
         int no_active = session_active_clients(cl->session);
+        yaz_log(YLOG_DEBUG, "%s: releasing watches on zero active: %d", client_get_url(cl), no_active);
         if (no_active == 0) {
             session_alert_watch(cl->session, SESSION_WATCH_SHOW);
             session_alert_watch(cl->session, SESSION_WATCH_SHOW_PREF);
@@ -445,16 +447,24 @@ static void ingest_raw_record(struct client *cl, ZOOM_record rec)
     client_show_raw_dequeue(cl);
 }
 
-static void client_check_preferred_watch(struct client *cl)
+void client_check_preferred_watch(struct client *cl)
 {
     struct session *se = cl->session;
+    yaz_log(YLOG_DEBUG, "client_check_preferred_watch: %s ", client_get_url(cl));
     if (se)
     {
         client_unlock(cl);
-        if (session_preferred_clients_ready(se))
+        if (session_is_preferred_clients_ready(se)) {
             session_alert_watch(se, SESSION_WATCH_SHOW_PREF);
+        }
+        else
+            yaz_log(YLOG_DEBUG, "client_check_preferred_watch: Still locked on preferred targets.");
+
         client_lock(cl);
     }
+    else
+        yaz_log(YLOG_WARN, "client_check_preferred_watch: %s. No session!", client_get_url(cl));
+
 }
 
 void client_search_response(struct client *cl)
@@ -475,13 +485,16 @@ void client_search_response(struct client *cl)
     }
     else
     {
+        yaz_log(YLOG_DEBUG, "client_search_response: hits "
+                ODR_INT_PRINTF, cl->hits);
         client_report_facets(cl, resultset);
         cl->record_offset = cl->startrecs;
         cl->hits = ZOOM_resultset_size(resultset);
-        if (se)
+        if (se) {
             se->total_hits += cl->hits;
-        if (cl->preferred)
-            client_check_preferred_watch(cl);
+            yaz_log(YLOG_DEBUG, "client_search_response: total hits "
+                    ODR_INT_PRINTF, se->total_hits);
+        }
     }
 }
 
@@ -655,7 +668,8 @@ void client_start_search(struct client *cl)
 
     if (opt_preferred) {
         cl->preferred = atoi(opt_preferred);
-        yaz_log(YLOG_LOG, "Target %s has preferred: %d", sdb->database->url, cl->preferred);
+        if (cl->preferred)
+            yaz_log(YLOG_LOG, "Target %s has preferred status: %d", sdb->database->url, cl->preferred);
     }
     client_set_state(cl, Client_Working);