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
Clean up maxrec and set the cl->maxrecs
[pazpar2-moved-to-github.git]
/
src
/
client.c
diff --git
a/src/client.c
b/src/client.c
index
fad815c
..
61e0a8a
100644
(file)
--- a/
src/client.c
+++ b/
src/client.c
@@
-1,5
+1,5
@@
/* This file is part of Pazpar2.
/* This file is part of Pazpar2.
- Copyright (C) 2006-2010 Index Data
+ Copyright (C) 2006-2011 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
@@
-103,6
+103,8
@@
struct client {
ZOOM_resultset resultset;
YAZ_MUTEX mutex;
int ref_count;
ZOOM_resultset resultset;
YAZ_MUTEX mutex;
int ref_count;
+ /* copy of database->url */
+ char *url;
};
struct show_raw {
};
struct show_raw {
@@
-592,6
+594,10
@@
static int client_set_facets_request(struct client *cl, ZOOM_connection link)
struct session_database *sdb = client_get_database(cl);
const char *opt_facet_term_sort = session_setting_oneval(sdb, PZ_TERMLIST_TERM_SORT);
const char *opt_facet_term_count = session_setting_oneval(sdb, PZ_TERMLIST_TERM_COUNT);
struct session_database *sdb = client_get_database(cl);
const char *opt_facet_term_sort = session_setting_oneval(sdb, PZ_TERMLIST_TERM_SORT);
const char *opt_facet_term_count = session_setting_oneval(sdb, PZ_TERMLIST_TERM_COUNT);
+
+ /* Future record filtering on target */
+ /* const char *opt_facet_record_filter = session_setting_oneval(sdb, PZ_RECORDFILTER); */
+
/* Disable when no count is set */
/* TODO Verify: Do we need to reset the ZOOM facets if a ZOOM Connection is being reused??? */
if (opt_facet_term_count && *opt_facet_term_count)
/* Disable when no count is set */
/* TODO Verify: Do we need to reset the ZOOM facets if a ZOOM Connection is being reused??? */
if (opt_facet_term_count && *opt_facet_term_count)
@@
-686,18
+692,19
@@
void client_start_search(struct client *cl)
if (*opt_requestsyn)
ZOOM_connection_option_set(link, "preferredRecordSyntax", opt_requestsyn);
if (*opt_requestsyn)
ZOOM_connection_option_set(link, "preferredRecordSyntax", opt_requestsyn);
- if (!*opt_maxrecs)
+ if (opt_maxrecs && *opt_maxrecs)
{
{
- sprintf(maxrecs_str, "%d", cl->maxrecs);
- opt_maxrecs = maxrecs_str;
+ cl->maxrecs = atoi(opt_maxrecs);
}
}
- ZOOM_connection_option_set(link, "count", opt_maxrecs);
+ /* convert back to string representation used in ZOOM API */
+ sprintf(maxrecs_str, "%d", cl->maxrecs);
+ ZOOM_connection_option_set(link, "count", maxrecs_str);
- if (atoi(opt_maxrecs) > 20)
+ if (cl->maxrecs > 20)
ZOOM_connection_option_set(link, "presentChunk", "20");
else
ZOOM_connection_option_set(link, "presentChunk", "20");
else
- ZOOM_connection_option_set(link, "presentChunk", opt_maxrecs);
+ ZOOM_connection_option_set(link, "presentChunk", maxrecs_str);
sprintf(startrecs_str, "%d", cl->startrecs);
ZOOM_connection_option_set(link, "start", startrecs_str);
sprintf(startrecs_str, "%d", cl->startrecs);
ZOOM_connection_option_set(link, "start", startrecs_str);
@@
-749,6
+756,7
@@
struct client *client_create(void)
pazpar2_mutex_create(&cl->mutex, "client");
cl->preferred = 0;
cl->ref_count = 1;
pazpar2_mutex_create(&cl->mutex, "client");
cl->preferred = 0;
cl->ref_count = 1;
+ cl->url = 0;
client_use(1);
return cl;
client_use(1);
return cl;
@@
-783,6
+791,7
@@
int client_destroy(struct client *c)
c->pquery = 0;
xfree(c->cqlquery);
c->cqlquery = 0;
c->pquery = 0;
xfree(c->cqlquery);
c->cqlquery = 0;
+ xfree(c->url);
assert(!c->connection);
if (c->resultset)
assert(!c->connection);
if (c->resultset)
@@
-1044,6
+1053,10
@@
int client_get_diagnostic(struct client *cl)
void client_set_database(struct client *cl, struct session_database *db)
{
cl->database = db;
void client_set_database(struct client *cl, struct session_database *db)
{
cl->database = db;
+ /* Copy the URL for safe logging even after session is gone */
+ if (db) {
+ cl->url = xstrdup(db->database->url);
+ }
}
struct host *client_get_host(struct client *cl)
}
struct host *client_get_host(struct client *cl)
@@
-1053,9
+1066,10
@@
struct host *client_get_host(struct client *cl)
const char *client_get_url(struct client *cl)
{
const char *client_get_url(struct client *cl)
{
- if (cl->database)
- return client_get_database(cl)->database->url;
+ if (cl->url)
+ return cl->url;
else
else
+ /* This must not happen anymore, as the url is present until destruction of client */
return "NOURL";
}
return "NOURL";
}
@@
-1064,6
+1078,11
@@
void client_set_maxrecs(struct client *cl, int v)
cl->maxrecs = v;
}
cl->maxrecs = v;
}
+int client_get_maxrecs(struct client *cl)
+{
+ return cl->maxrecs;
+}
+
void client_set_startrecs(struct client *cl, int v)
{
cl->startrecs = v;
void client_set_startrecs(struct client *cl, int v)
{
cl->startrecs = v;