Added exact match record filter
[pazpar2-moved-to-github.git] / src / session.c
index ea09249..76364aa 100644 (file)
@@ -446,6 +446,7 @@ void session_alert_watch(struct session *s, int what)
         s->watchlist[what].obs = 0;
 
         session_leave(s);
+        yaz_log(YLOG_DEBUG, "session_alert_watch: %d calling function: %p", what, fun);
         fun(data);
     }
     else
@@ -509,7 +510,7 @@ int session_active_clients(struct session *s)
     return res;
 }
 
-int session_preferred_clients_ready(struct session *s)
+int session_is_preferred_clients_ready(struct session *s)
 {
     struct client_list *l;
     int res = 0;
@@ -517,7 +518,7 @@ int session_preferred_clients_ready(struct session *s)
     for (l = s->clients; l; l = l->next)
         if (client_is_active_preferred(l->client))
             res++;
-
+    yaz_log(YLOG_DEBUG, "%p Session has %d active preferred clients.", s, res);
     return res == 0;
 }
 
@@ -1124,9 +1125,15 @@ static int check_record_filter(xmlNode *root, struct session_database *sdb)
             if (type)
             {
                 size_t len;
-                const char *eq = strchr(s, '~');
-                if (eq)
-                    len = eq - s;
+               int substring;
+                const char *eq;
+
+                if ((eq = strchr(s, '=')))
+                   substring = 0;
+               else if ((eq = strchr(s, '~')))
+                   substring = 1;
+               if (eq)
+                   len = eq - s;
                 else
                     len = strlen(s);
                 if (len == strlen((const char *)type) &&
@@ -1135,7 +1142,9 @@ static int check_record_filter(xmlNode *root, struct session_database *sdb)
                     xmlChar *value = xmlNodeGetContent(n);
                     if (value && *value)
                     {
-                        if (!eq || strstr((const char *) value, eq+1))
+                        if (!eq ||
+                           (substring && strstr((const char *) value, eq+1)) ||
+                           (!substring && !strcmp((const char *) value, eq + 1)))
                             match = 1;
                     }
                     xmlFree(value);