projects
/
pazpar2-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add filtered record count to bytarget response
[pazpar2-moved-to-github.git]
/
src
/
session.c
diff --git
a/src/session.c
b/src/session.c
index
425d6ca
..
1f55a87
100644
(file)
--- a/
src/session.c
+++ b/
src/session.c
@@
-1,5
+1,5
@@
/* This file is part of Pazpar2.
/* This file is part of Pazpar2.
- Copyright (C) 2006-2011 Index Data
+ Copyright (C) 2006-2012 Index Data
Pazpar2 is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Pazpar2 is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
@@
-76,6
+76,8
@@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "settings.h"
#include "normalize7bit.h"
#include "settings.h"
#include "normalize7bit.h"
+#include <libxml/tree.h>
+
#define TERMLIST_HIGH_SCORE 25
#define MAX_CHUNK 15
#define TERMLIST_HIGH_SCORE 25
#define MAX_CHUNK 15
@@
-523,13
+525,14
@@
static void select_targets_callback(struct session *se,
{
cl = client_create(db->database->id);
client_set_database(cl, db);
{
cl = client_create(db->database->id);
client_set_database(cl, db);
- client_set_session(cl, se);
l = xmalloc(sizeof(*l));
l->client = cl;
l->next = se->clients_cached;
se->clients_cached = l;
}
l = xmalloc(sizeof(*l));
l->client = cl;
l->next = se->clients_cached;
se->clients_cached = l;
}
+ /* set session always. If may be 0 if client is not active */
+ client_set_session(cl, se);
l = xmalloc(sizeof(*l));
l->client = cl;
l = xmalloc(sizeof(*l));
l->client = cl;
@@
-550,6
+553,11
@@
static void session_reset_active_clients(struct session *se,
while (l)
{
struct client_list *l_next = l->next;
while (l)
{
struct client_list *l_next = l->next;
+
+ client_lock(l->client);
+ client_set_session(l->client, 0); /* mark client inactive */
+ client_unlock(l->client);
+
xfree(l);
l = l_next;
}
xfree(l);
l = l_next;
}
@@
-642,11
+650,9
@@
void session_sort(struct session *se, const char *field, int increasing)
for (l = se->clients_active; l; l = l->next)
{
struct client *cl = l->client;
for (l = se->clients_active; l; l = l->next)
{
struct client *cl = l->client;
- struct timeval tval;
- if (client_prep_connection(cl, se->service->z3950_operation_timeout,
- se->service->z3950_session_timeout,
- se->service->server->iochan_man,
- &tval))
+ if (client_get_state(cl) == Client_Connecting ||
+ client_get_state(cl) == Client_Idle ||
+ client_get_state(cl) == Client_Working)
client_start_search(cl);
}
session_leave(se);
client_start_search(cl);
}
session_leave(se);
@@
-743,7
+749,7
@@
enum pazpar2_error_code session_search(struct session *se,
session_log(se, YLOG_LOG, "client REUSE %s", client_get_id(cl));
client_reingest(cl);
}
session_log(se, YLOG_LOG, "client REUSE %s", client_get_id(cl));
client_reingest(cl);
}
- else
+ else if (r)
{
session_log(se, YLOG_LOG, "client NEW %s", client_get_id(cl));
client_start_search(cl);
{
session_log(se, YLOG_LOG, "client NEW %s", client_get_id(cl));
client_start_search(cl);
@@
-958,6
+964,7
@@
static struct hitsbytarget *hitsbytarget_nb(struct session *se,
res[*count].name = *name ? name : "Unknown";
res[*count].hits = client_get_hits(cl);
res[*count].records = client_get_num_records(cl);
res[*count].name = *name ? name : "Unknown";
res[*count].hits = client_get_hits(cl);
res[*count].records = client_get_num_records(cl);
+ res[*count].filtered = client_get_num_records_filtered(cl);
res[*count].diagnostic =
client_get_diagnostic(cl, &res[*count].addinfo);
res[*count].state = client_get_state_str(cl);
res[*count].diagnostic =
client_get_diagnostic(cl, &res[*count].addinfo);
res[*count].state = client_get_state_str(cl);
@@
-1065,7
+1072,8
@@
void perform_termlist(struct http_channel *c, struct session *se,
for (j = 0; j < num_names; j++)
{
const char *tname;
for (j = 0; j < num_names; j++)
{
const char *tname;
-
+ int must_generate_empty = 1; /* bug 5350 */
+
for (i = 0; i < se->num_termlists; i++)
{
tname = se->termlists[i].name;
for (i = 0; i < se->num_termlists; i++)
{
tname = se->termlists[i].name;
@@
-1077,6
+1085,7
@@
void perform_termlist(struct http_channel *c, struct session *se,
wrbuf_puts(c->wrbuf, "<list name=\"");
wrbuf_xmlputs(c->wrbuf, tname);
wrbuf_puts(c->wrbuf, "\">\n");
wrbuf_puts(c->wrbuf, "<list name=\"");
wrbuf_xmlputs(c->wrbuf, tname);
wrbuf_puts(c->wrbuf, "\">\n");
+ must_generate_empty = 0;
p = termlist_highscore(se->termlists[i].termlist, &len);
if (p)
p = termlist_highscore(se->termlists[i].termlist, &len);
if (p)
@@
-1111,6
+1120,13
@@
void perform_termlist(struct http_channel *c, struct session *se,
targets_termlist_nb(c->wrbuf, se, num, c->nmem);
wrbuf_puts(c->wrbuf, "</list>\n");
targets_termlist_nb(c->wrbuf, se, num, c->nmem);
wrbuf_puts(c->wrbuf, "</list>\n");
+ must_generate_empty = 0;
+ }
+ if (must_generate_empty)
+ {
+ wrbuf_puts(c->wrbuf, "<list name=\"");
+ wrbuf_xmlputs(c->wrbuf, names[j]);
+ wrbuf_puts(c->wrbuf, "\"/>\n");
}
}
session_leave(se);
}
}
session_leave(se);
@@
-1528,8
+1544,7
@@
int ingest_record(struct client *cl, const char *rec,
if (!check_record_filter(root, sdb))
{
if (!check_record_filter(root, sdb))
{
- session_log(se, YLOG_LOG, "Filtered out record no %d from %s",
- record_no, sdb->database->id);
+ session_log(se, YLOG_LOG, "Filtered out record no %d from %s", record_no, sdb->database->id);
xmlFreeDoc(xdoc);
return -2;
}
xmlFreeDoc(xdoc);
return -2;
}