#include <config.h>
#endif
+#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
+#ifdef WIN32
+#include <windows.h>
+#endif
#include <signal.h>
#include <ctype.h>
#include <assert.h>
#include <yaz/querytowrbuf.h>
#include <yaz/oid_db.h>
#include <yaz/snprintf.h>
+#include <yaz/gettimeofday.h>
#define USE_TIMING 0
#if USE_TIMING
}
-static void add_facet(struct session *s, const char *type, const char *value)
+void add_facet(struct session *s, const char *type, const char *value, int count)
{
int i;
= termlist_create(s->nmem, TERMLIST_HIGH_SCORE);
s->num_termlists = i + 1;
}
- termlist_insert(s->termlists[i].termlist, value);
+ yaz_log(YLOG_DEBUG, "Session: facets for %s: %s (%d)", type, value, count);
+
+ termlist_insert(s->termlists[i].termlist, value, count);
}
static xmlDoc *record_to_xml(struct session_database *sdb, const char *rec)
session_watchfun fun;
http_remove_observer(s->watchlist[what].obs);
- fun = s->watchlist[what].fun;
+ fun = s->watchlist[what].fun;
data = s->watchlist[what].data;
/* reset watch before fun is invoked - in case fun wants to set
s->watchlist[what].obs = 0;
session_leave(s);
+ yaz_log(YLOG_DEBUG, "session_alert_watch: %d calling function: %p", what, fun);
fun(data);
}
else
return res;
}
+int session_is_preferred_clients_ready(struct session *s)
+{
+ struct client_list *l;
+ int res = 0;
+
+ 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;
+}
+
+
enum pazpar2_error_code search(struct session *se,
const char *query,
int no_working = 0;
int no_failed = 0;
struct client_list *l;
+ struct timeval tval;
yaz_log(YLOG_DEBUG, "Search");
}
se->reclist = reclist_create(se->nmem);
+ yaz_gettimeofday(&tval);
+
+ tval.tv_sec += 5;
+
for (l = se->clients; l; l = l->next)
{
struct client *cl = l->client;
no_working++;
if (client_prep_connection(cl, se->service->z3950_operation_timeout,
se->service->z3950_session_timeout,
- se->service->server->iochan_man))
+ se->service->server->iochan_man,
+ &tval))
client_start_search(cl);
}
}
if (!strcmp((const char *) n->name, "metadata"))
{
xmlChar *type = xmlGetProp(n, (xmlChar *) "type");
- if (!strcmp(name, (const char *) type))
+ if (type == NULL) {
+ yaz_log(YLOG_FATAL, "Missing type attribute on metadata element. Skipping!");
+ }
+ else if (!strcmp(name, (const char *) type))
{
xmlChar *value = xmlNodeListGetString(doc, n->children, 1);
if (value)
\param cl client holds the result set for record
\param rec record buffer (0 terminated)
\param record_no record position (1, 2, ..)
+ \param nmem working NMEM
\retval 0 OK
\retval -1 failure
*/
(char *) value, ser_md->rank,
ser_md->name);
- // construct facets ...
- if (ser_md->termlist)
+ // construct facets ... unless the client already has reported them
+ if (ser_md->termlist && !client_has_facet(cl, (char *) type))
{
+
if (ser_md->type == Metadata_type_year)
{
char year[64];
sprintf(year, "%d", rec_md->data.number.max);
- add_facet(se, (char *) type, year);
+ add_facet(se, (char *) type, year, 1);
if (rec_md->data.number.max != rec_md->data.number.min)
{
sprintf(year, "%d", rec_md->data.number.min);
- add_facet(se, (char *) type, year);
+ add_facet(se, (char *) type, year, 1);
}
}
else
- add_facet(se, (char *) type, (char *) value);
+ add_facet(se, (char *) type, (char *) value, 1);
}
// cleaning up