+--- 1.4.0 2010/03/29
+
+Pazpar2 may operate in threaded mode. Enabled by element threads in
+the configuration. See pazpar2_conf for details.
+
+New setting setting: pz:max_connections. Setting pz:max_connections is
+a limit of number of sockets to a host. When this limit is reached,
+Pazpar2 will wait up to 5 seconds for a connection to becomes available.
+The client will be marked Client_Error when it can not be searched
+(other clients in a session may work). If pz:max_connections is not set
+for a target, a value of 30 will be used. Note: the pz:max_connections
+will only work in threaded mode.
+
+pz2.js: JSON support for show.
+
+Debian package: Enable default service, default.xml, before starting
+Pazpar2 only if there is no service already in /etc/pazpar2/services-enabled.
+
--- 1.3.0 2010/01/25
Debian version depends on on libyaz4. Note that Pazpar2 will still
# Autoconf and automake setup
AC_PREREQ(2.60)
-AC_INIT([pazpar2],[1.3.0],[pazpar2-help@indexdata.dk])
+AC_INIT([pazpar2],[1.4.0],[pazpar2-help@indexdata.dk])
AC_CONFIG_HEADERS(src/config.h)
+pazpar2 (1.4.0-1indexdata) unstable; urgency=low
+
+ * Upstream.
+
+ -- Adam Dickmeiss <adam@indexdata.dk> Thu, 29 Apr 2010 13:07:13 +0200
+
pazpar2 (1.3.0-1indexdata) unstable; urgency=low
* Upstream.
Section: net
Priority: extra
Maintainer: Adam Dickmeiss <adam@indexdata.dk>
-Build-Depends: debhelper (>= 5), autotools-dev, libyaz4-dev (>= 4.0.4), docbook-xsl
+Build-Depends: debhelper (>= 5), autotools-dev, libyaz4-dev (>= 4.0.4), docbook-xsl, libgnutls-dev
Standards-Version: 3.7.2
Package: pazpar2
*.log
*.xml
+*.time
+run*
#!/bin/bash
DELAY=0.001
WAIT=5
-NUMBER=40
+NUMBER=10
ROUNDS=5
if test -n "$1"; then
. $1
/* This file is part of Pazpar2.
- Copyright (C) 2006-2010 Index Data
+ Copyright (C) 2006-2010 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
-Software Foundation; either version 2, or (at your option) any later
-version.
+ 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
+ Software Foundation; either version 2, or (at your option) any later
+ version.
-Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
+ Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
/*
* Based on ParaZ - a simple tool for harvesting performance data for
#include <yaz/log.h>
#include <yaz/comstack.h>
#include <yaz/xmalloc.h>
+#include <yaz/mutex.h>
+#include <yaz/poll.h>
#include "eventl.h"
#include "sel_thread.h"
int sel_fd;
int no_threads;
int log_level;
+ YAZ_MUTEX iochan_mutex;
};
-iochan_man_t iochan_man_create(int no_threads)
-{
+iochan_man_t iochan_man_create(int no_threads) {
iochan_man_t man = xmalloc(sizeof(*man));
man->channel_list = 0;
man->sel_thread = 0; /* can't create sel_thread yet because we may fork */
man->sel_fd = -1;
man->no_threads = no_threads;
man->log_level = yaz_log_module_level("iochan");
-
+ man->iochan_mutex = 0;
+ yaz_mutex_create(&man->iochan_mutex);
return man;
}
-void iochan_man_destroy(iochan_man_t *mp)
-{
- if (*mp)
- {
+void iochan_man_destroy(iochan_man_t *mp) {
+ if (*mp) {
IOCHAN c;
if ((*mp)->sel_thread)
sel_thread_destroy((*mp)->sel_thread);
-
+
+ yaz_mutex_enter((*mp)->iochan_mutex);
c = (*mp)->channel_list;
- while (c)
- {
+ (*mp)->channel_list = NULL;
+ yaz_mutex_leave((*mp)->iochan_mutex);
+ while (c) {
IOCHAN c_next = c->next;
xfree(c->name);
xfree(c);
}
}
-void iochan_add(iochan_man_t man, IOCHAN chan)
-{
+void iochan_add(iochan_man_t man, IOCHAN chan) {
chan->man = man;
+ yaz_mutex_enter(man->iochan_mutex);
+ yaz_log(man->log_level, "iochan_add : chan=%p channel list=%p", chan,
+ man->channel_list);
chan->next = man->channel_list;
man->channel_list = chan;
+ yaz_mutex_leave(man->iochan_mutex);
}
-IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags,
- const char *name)
-{
+IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags, const char *name) {
IOCHAN new_iochan;
- if (!(new_iochan = (IOCHAN)xmalloc(sizeof(*new_iochan))))
- return 0;
+ if (!(new_iochan = (IOCHAN) xmalloc(sizeof(*new_iochan))))
+ return 0;
new_iochan->destroyed = 0;
new_iochan->fd = fd;
new_iochan->flags = flags;
return new_iochan;
}
-static void work_handler(void *work_data)
-{
+static void work_handler(void *work_data) {
IOCHAN p = work_data;
yaz_log(p->man->log_level, "eventl: work begin chan=%p name=%s event=%d",
p, p->name ? p->name : "", p->this_event);
-
+
if (!p->destroyed && (p->this_event & EVENT_TIMEOUT))
(*p->fun)(p, EVENT_TIMEOUT);
if (!p->destroyed && (p->this_event & EVENT_INPUT))
if (!p->destroyed && (p->this_event & EVENT_EXCEPT))
(*p->fun)(p, EVENT_EXCEPT);
- yaz_log(p->man->log_level, "eventl: work end chan=%p name=%s event=%d",
- p, p->name ? p->name : "", p->this_event);
+ yaz_log(p->man->log_level, "eventl: work end chan=%p name=%s event=%d", p,
+ p->name ? p->name : "", p->this_event);
}
-static void run_fun(iochan_man_t man, IOCHAN p)
-{
- if (p->this_event)
- {
- if (man->sel_thread)
- {
- yaz_log(man->log_level, "eventl: work add chan=%p name=%s event=%d",
- p, p->name ? p->name : "", p->this_event);
+static void run_fun(iochan_man_t man, IOCHAN p) {
+ if (p->this_event) {
+ if (man->sel_thread) {
+ yaz_log(man->log_level,
+ "eventl: work add chan=%p name=%s event=%d", p,
+ p->name ? p->name : "", p->this_event);
p->thread_users++;
sel_thread_add(man->sel_thread, p);
- }
- else
+ } else
work_handler(p);
}
}
-static int event_loop(iochan_man_t man, IOCHAN *iochans)
-{
+static int event_loop(iochan_man_t man, IOCHAN *iochans) {
do /* loop as long as there are active associations to process */
{
- IOCHAN p, *nextp;
- fd_set in, out, except;
- int res, max;
- static struct timeval to;
- struct timeval *timeout;
-
- FD_ZERO(&in);
- FD_ZERO(&out);
- FD_ZERO(&except);
- timeout = &to; /* hang on select */
- to.tv_sec = 300;
- to.tv_usec = 0;
- max = 0;
- for (p = *iochans; p; p = p->next)
- {
+ IOCHAN p, *nextp;
+ IOCHAN start;
+ IOCHAN inv_start;
+ fd_set in, out, except;
+ int res, max;
+ static struct timeval to;
+ struct timeval *timeout;
+
+// struct yaz_poll_fd *fds;
+ int no_fds = 0;
+ FD_ZERO(&in);
+ FD_ZERO(&out);
+ FD_ZERO(&except);
+ timeout = &to; /* hang on select */
+ to.tv_sec = 300;
+ to.tv_usec = 0;
+
+ // INV: start must no change through the loop
+
+ yaz_mutex_enter(man->iochan_mutex);
+ start = man->channel_list;
+ yaz_mutex_leave(man->iochan_mutex);
+ inv_start = start;
+ for (p = start; p; p = p->next) {
+ no_fds++;
+ }
+// fds = (struct yaz_poll_fd *) xmalloc(no_fds * sizeof(*fds));
+
+ max = 0;
+ for (p = start; p; p = p->next) {
if (p->thread_users > 0)
continue;
if (p->max_idle && p->max_idle < to.tv_sec)
to.tv_sec = p->max_idle;
if (p->fd < 0)
continue;
- if (p->flags & EVENT_INPUT)
- FD_SET(p->fd, &in);
- if (p->flags & EVENT_OUTPUT)
- FD_SET(p->fd, &out);
- if (p->flags & EVENT_EXCEPT)
- FD_SET(p->fd, &except);
- if (p->fd > max)
- max = p->fd;
- }
- if (man->sel_fd != -1)
- {
+ if (p->flags & EVENT_INPUT)
+ FD_SET(p->fd, &in);
+ if (p->flags & EVENT_OUTPUT)
+ FD_SET(p->fd, &out);
+ if (p->flags & EVENT_EXCEPT)
+ FD_SET(p->fd, &except);
+ if (p->fd > max)
+ max = p->fd;
+ }
+ yaz_log(man->log_level, "max=%d nofds=%d", max, man->sel_fd);
+
+ if (man->sel_fd != -1) {
if (man->sel_fd > max)
max = man->sel_fd;
FD_SET(man->sel_fd, &in);
yaz_log(man->log_level, "select begin nofds=%d", max);
res = select(max + 1, &in, &out, &except, timeout);
yaz_log(man->log_level, "select returned res=%d", res);
- if (res < 0)
- {
- if (errno == EINTR)
- continue;
- else
- {
- yaz_log(YLOG_ERRNO|YLOG_WARN, "select");
+ if (res < 0) {
+ if (errno == EINTR)
+ continue;
+ else {
+ yaz_log(YLOG_ERRNO | YLOG_WARN, "select");
return 0;
}
- }
- if (man->sel_fd != -1)
- {
- if (FD_ISSET(man->sel_fd, &in))
- {
+ }
+ if (man->sel_fd != -1) {
+ if (FD_ISSET(man->sel_fd, &in)) {
IOCHAN chan;
yaz_log(man->log_level, "eventl: sel input on sel_fd=%d",
man->sel_fd);
- while ((chan = sel_thread_result(man->sel_thread)))
- {
- yaz_log(man->log_level, "eventl: got thread result chan=%p name=%s",
- chan, chan->name ? chan->name : "");
+ while ((chan = sel_thread_result(man->sel_thread))) {
+ yaz_log(man->log_level,
+ "eventl: got thread result chan=%p name=%s", chan,
+ chan->name ? chan->name : "");
chan->thread_users--;
}
}
}
- if (man->log_level)
- {
+ if (man->log_level) {
int no = 0;
- for (p = *iochans; p; p = p->next)
+ for (p = start; p; p = p->next) {
no++;
+ }
yaz_log(man->log_level, "%d channels", no);
}
- for (p = *iochans; p; p = p->next)
- {
+ for (p = start; p; p = p->next) {
time_t now = time(0);
-
- if (p->destroyed)
- {
- yaz_log(man->log_level, "eventl: skip destroyed chan=%p name=%s", p, p->name ? p->name : "");
+
+ if (p->destroyed) {
+ yaz_log(man->log_level,
+ "eventl: skip destroyed chan=%p name=%s", p,
+ p->name ? p->name : "");
continue;
}
- if (p->thread_users > 0)
- {
- yaz_log(man->log_level, "eventl: skip chan=%p name=%s users=%d", p, p->name ? p->name : "", p->thread_users);
+ if (p->thread_users > 0) {
+ yaz_log(man->log_level,
+ "eventl: skip chan=%p name=%s users=%d", p,
+ p->name ? p->name : "", p->thread_users);
continue;
}
p->this_event = 0;
- if (p->max_idle && now - p->last_event > p->max_idle)
- {
+ if (p->max_idle && now - p->last_event > p->max_idle) {
p->last_event = now;
p->this_event |= EVENT_TIMEOUT;
}
- if (p->fd >= 0)
- {
- if (FD_ISSET(p->fd, &in))
- {
+ if (p->fd >= 0) {
+ if (FD_ISSET(p->fd, &in)) {
p->last_event = now;
p->this_event |= EVENT_INPUT;
}
- if (FD_ISSET(p->fd, &out))
- {
+ if (FD_ISSET(p->fd, &out)) {
p->last_event = now;
p->this_event |= EVENT_OUTPUT;
}
- if (FD_ISSET(p->fd, &except))
- {
+ if (FD_ISSET(p->fd, &except)) {
p->last_event = now;
p->this_event |= EVENT_EXCEPT;
}
}
run_fun(man, p);
- }
- for (nextp = iochans; *nextp; )
- {
+ }
+ assert(inv_start == start);
+ yaz_mutex_enter(man->iochan_mutex);
+ for (nextp = iochans; *nextp;) {
IOCHAN p = *nextp;
- if (p->destroyed && p->thread_users == 0)
- {
+ if (p->destroyed && p->thread_users == 0) {
*nextp = p->next;
xfree(p->name);
xfree(p);
- }
- else
+ } else
nextp = &p->next;
}
- }
- while (*iochans);
+ yaz_mutex_leave(man->iochan_mutex);
+ } while (*iochans);
return 0;
}
-void iochan_man_events(iochan_man_t man)
-{
- if (man->no_threads > 0 && !man->sel_thread)
- {
- man->sel_thread = sel_thread_create(
- work_handler, 0 /*work_destroy */, &man->sel_fd, man->no_threads);
+void iochan_man_events(iochan_man_t man) {
+ if (man->no_threads > 0 && !man->sel_thread) {
+ man->sel_thread = sel_thread_create(work_handler, 0 /*work_destroy */,
+ &man->sel_fd, man->no_threads);
yaz_log(man->log_level, "iochan_man_events. Using %d threads",
man->no_threads);
}
event_loop(man, &man->channel_list);
}
-void pazpar2_sleep(double d)
-{
+void pazpar2_sleep(double d) {
#ifdef WIN32
Sleep( (DWORD) (d * 1000));
#else
struct http_sessions {
struct http_session *session_list;
YAZ_MUTEX mutex;
+ int log_level;
};
http_sessions_t http_sessions_create(void)
hs->session_list = 0;
hs->mutex = 0;
pazpar2_mutex_create(&hs->mutex, "http_sessions");
+ hs->log_level = yaz_log_module_level("HTTP");
return hs;
}
r->timeout_iochan = iochan_create(-1, session_timeout, 0, "http_session_timeout");
iochan_setdata(r->timeout_iochan, r);
- yaz_log(YLOG_LOG, "timeout=%d", service->session_timeout);
+ yaz_log(http_sessions->log_level, "%p Session %u created. timeout chan=%p timeout=%d", r, sesid, r->timeout_iochan, service->session_timeout);
iochan_settimeout(r->timeout_iochan, service->session_timeout);
iochan_add(service->server->iochan_man, r->timeout_iochan);
void http_session_destroy(struct http_session *s)
{
- int must_destroy = 1;
+ int must_destroy = 0;
http_sessions_t http_sessions = s->http_sessions;
- yaz_log(YLOG_LOG, "http_session_destroy %u", s->session_id);
+ yaz_log(http_sessions->log_level, "%p Session %u destroyed", s, s->session_id);
yaz_mutex_enter(http_sessions->mutex);
-
- /* only if http_session destroy was already called, we will allow it
- to be destroyed */
- if (s->destroy_counter != s->activity_counter)
- must_destroy = 0;
-
- s->destroy_counter = s->activity_counter = 0;
- if (must_destroy)
- {
+ /* only if http_session has no active http sessions on it can be destroyed */
+ if (s->destroy_counter == s->activity_counter) {
struct http_session **p = 0;
+ must_destroy = 1;
for (p = &http_sessions->session_list; *p; p = &(*p)->next)
if (*p == s)
{
yaz_mutex_leave(http_sessions->mutex);
if (must_destroy)
{ /* destroying for real */
- yaz_log(YLOG_LOG, "Destroying session %u", s->session_id);
+ yaz_log(http_sessions->log_level, "%p Session %u destroyed", s, s->session_id);
iochan_destroy(s->timeout_iochan);
destroy_session(s->psession);
nmem_destroy(s->nmem);
}
else {
- yaz_log(YLOG_LOG, "Active clients on session %u. Waiting for new timeout.", s->session_id);
+ yaz_log(http_sessions->log_level, "%p Session %u destroyed delayed. Active clients (%d-%d). Waiting for new timeout.",
+ s, s->session_id, s->activity_counter, s->destroy_counter);
}
}
return p;
}
+// Call after use of locate_session, in order to increment the destroy_counter
+static void release_session(struct http_channel *c, struct http_session *session) {
+ http_sessions_t http_sessions = c->http_sessions;
+ yaz_mutex_enter(http_sessions->mutex);
+ if (session)
+ session->destroy_counter++;
+ yaz_mutex_leave(http_sessions->mutex);
+}
+
// Decode settings parameters and apply to session
// Syntax: setting[target]=value
static int process_settings(struct session *se, struct http_request *rq,
sesid = make_sessionid();
s = http_session_create(service, c->http_sessions, sesid);
- yaz_log(YLOG_DEBUG, "HTTP Session init");
+ yaz_log(c->http_sessions->log_level, "%p Session init %u ", s, sesid);
if (!clear || *clear == '0')
session_init_databases(s->psession);
else
- yaz_log(YLOG_LOG, "No databases preloaded");
+ yaz_log(YLOG_LOG, "HTTP Session %u init: No databases preloaded", sesid);
if (process_settings(s->psession, c->request, c->response) < 0)
return;
xmlFreeDoc(doc);
}
- if (process_settings(s->psession, rq, rs) < 0)
+ if (process_settings(s->psession, rq, rs) < 0) {
+ release_session(c,s);
return;
+ }
rs->payload = HTTP_COMMAND_RESPONSE_PREFIX "<settings><status>OK</status></settings>";
http_send_response(c);
+ release_session(c,s);
}
// Compares two hitsbytarget nodes by hitcount
wrbuf_puts(c->wrbuf, "</termlist>\n");
rs->payload = nmem_strdup(rq->channel->nmem, wrbuf_cstr(c->wrbuf));
http_send_response(c);
+ release_session(c,s);
}
wrbuf_puts(c->wrbuf, "</bytarget>");
rs->payload = nmem_strdup(c->nmem, wrbuf_cstr(c->wrbuf));
http_send_response(c);
+ release_session(c,s);
}
static void write_metadata(WRBUF w, struct conf_service *service,
{
error(rs, PAZPAR2_RECORD_MISSING, idstr);
}
+ release_session(c, s);
return;
}
if (offsetstr)
http_send_response(c);
}
show_single_stop(s->psession, rec);
+ release_session(c, s);
}
static void cmd_record_ready(void *data)
if (!(sp = reclist_parse_sortparms(c->nmem, sort, s->psession->service)))
{
error(rs, PAZPAR2_MALFORMED_PARAMETER_VALUE, "sort");
+ release_session(c, s);
return;
}
wrbuf_puts(c->wrbuf, "</show>\n");
rs->payload = nmem_strdup(c->nmem, wrbuf_cstr(c->wrbuf));
http_send_response(c);
+ release_session(c, s);
}
static void show_records_ready(void *data)
if (session_set_watch(s->psession, SESSION_WATCH_SHOW,
show_records_ready, c, c) != 0)
{
- yaz_log(YLOG_DEBUG, "Blocking on cmd_show");
+ yaz_log(c->http_sessions->log_level, "%p Session %u: Blocking on cmd_show", s, s->session_id);
}
+ release_session(c,s);
return;
}
}
-
show_records(c, status);
+ release_session(c,s);
}
static void cmd_ping(struct http_channel *c)
return;
rs->payload = HTTP_COMMAND_RESPONSE_PREFIX "<ping><status>OK</status></ping>";
http_send_response(c);
+ release_session(c, s);
}
static int utf_8_valid(const char *str)
if (!query)
{
error(rs, PAZPAR2_MISSING_PARAMETER, "query");
+ release_session(c,s);
return;
}
if (!utf_8_valid(query))
{
error(rs, PAZPAR2_MALFORMED_PARAMETER_ENCODING, "query");
+ release_session(c,s);
return;
}
code = search(s->psession, query, startrecs, maxrecs, filter, &addinfo);
if (code)
{
error(rs, code, addinfo);
+ release_session(c,s);
return;
}
rs->payload = HTTP_COMMAND_RESPONSE_PREFIX "<search><status>OK</status></search>";
http_send_response(c);
+ release_session(c,s);
}
wrbuf_puts(c->wrbuf, "</stat>");
rs->payload = nmem_strdup(c->nmem, wrbuf_cstr(c->wrbuf));
http_send_response(c);
+ release_session(c,s);
}
static void cmd_info(struct http_channel *c)
void (*work_destroy)(void *work_data);
};
+static int input_queue_length = 0;
+
static void *sel_thread_handler(void *vp)
{
sel_thread_t p = (sel_thread_t) vp;
assert(p->input_queue);
work_this = queue_remove_last(&p->input_queue);
+ input_queue_length--;
+ yaz_log(YLOG_DEBUG, "input queue length after pop: %d", input_queue_length);
assert(work_this);
pthread_mutex_unlock(&p->mutex);
work_p->data = data;
work_p->next = p->input_queue;
p->input_queue = work_p;
-
+ input_queue_length++;
+ yaz_log(YLOG_DEBUG, "sel_thread_add: Input queue length after push: %d", input_queue_length);
pthread_cond_signal(&p->input_data);
pthread_mutex_unlock(&p->mutex);
}
}
}
-void destroy_session(struct session *s)
+void destroy_session(struct session *se)
{
struct session_database *sdb;
- session_remove_clients(s);
+ yaz_log(YLOG_DEBUG, "%p Pazpar2 session destroy", se);
+ session_remove_clients(se);
- for (sdb = s->databases; sdb; sdb = sdb->next)
+ for (sdb = se->databases; sdb; sdb = sdb->next)
session_database_destroy(sdb);
- normalize_cache_destroy(s->normalize_cache);
- relevance_destroy(&s->relevance);
- reclist_destroy(s->reclist);
- nmem_destroy(s->nmem);
- service_destroy(s->service);
- yaz_mutex_destroy(&s->session_mutex);
- wrbuf_destroy(s->wrbuf);
+ normalize_cache_destroy(se->normalize_cache);
+ relevance_destroy(&se->relevance);
+ reclist_destroy(se->reclist);
+ nmem_destroy(se->nmem);
+ service_destroy(se->service);
+ yaz_mutex_destroy(&se->session_mutex);
+ wrbuf_destroy(se->wrbuf);
}
struct session *new_session(NMEM nmem, struct conf_service *service,
int i;
struct session *session = nmem_malloc(nmem, sizeof(*session));
- yaz_log(YLOG_DEBUG, "New Pazpar2 session");
+ yaz_log(YLOG_DEBUG, "%p New Pazpar2 session", session);
session->service = service;
session->relevance = 0;
return res;
}
-struct termlist_score **termlist(struct session *s, const char *name, int *num)
+struct termlist_score **termlist(struct session *se, const char *name, int *num)
{
int i;
struct termlist_score **tl = 0;
- session_enter(s);
- for (i = 0; i < s->num_termlists; i++)
- if (!strcmp((const char *) s->termlists[i].name, name))
+ session_enter(se);
+ for (i = 0; i < se->num_termlists; i++)
+ if (!strcmp((const char *) se->termlists[i].name, name))
{
- tl = termlist_highscore(s->termlists[i].termlist, num);
+ tl = termlist_highscore(se->termlists[i].termlist, num);
break;
}
- session_leave(s);
+ session_leave(se);
return tl;
}
}
#endif
-struct record_cluster *show_single_start(struct session *s, const char *id,
+struct record_cluster *show_single_start(struct session *se, const char *id,
struct record_cluster **prev_r,
struct record_cluster **next_r)
{
struct record_cluster *r;
- session_enter(s);
- reclist_enter(s->reclist);
+ session_enter(se);
+ reclist_enter(se->reclist);
*prev_r = 0;
*next_r = 0;
- while ((r = reclist_read_record(s->reclist)))
+ while ((r = reclist_read_record(se->reclist)))
{
if (!strcmp(r->recid, id))
{
- *next_r = reclist_read_record(s->reclist);
+ *next_r = reclist_read_record(se->reclist);
break;
}
*prev_r = r;
}
- reclist_leave(s->reclist);
+ reclist_leave(se->reclist);
if (!r)
- session_leave(s);
+ session_leave(se);
return r;
}
-void show_single_stop(struct session *s, struct record_cluster *rec)
+void show_single_stop(struct session *se, struct record_cluster *rec)
{
- session_leave(s);
+ session_leave(se);
}
-struct record_cluster **show_range_start(struct session *s,
+struct record_cluster **show_range_start(struct session *se,
struct reclist_sortparms *sp,
int start, int *num, int *total, Odr_int *sumhits)
{
- struct record_cluster **recs = nmem_malloc(s->nmem, *num
- * sizeof(struct record_cluster *));
+ struct record_cluster **recs;
struct reclist_sortparms *spp;
int i;
#if USE_TIMING
yaz_timing_t t = yaz_timing_create();
#endif
-
- session_enter(s);
- if (!s->relevance)
+ session_enter(se);
+ recs = nmem_malloc(se->nmem, *num * sizeof(struct record_cluster *));
+ if (!se->relevance)
{
*num = 0;
*total = 0;
for (spp = sp; spp; spp = spp->next)
if (spp->type == Metadata_sortkey_relevance)
{
- relevance_prepare_read(s->relevance, s->reclist);
+ relevance_prepare_read(se->relevance, se->reclist);
break;
}
- reclist_sort(s->reclist, sp);
+ reclist_sort(se->reclist, sp);
- reclist_enter(s->reclist);
- *total = reclist_get_num_records(s->reclist);
- *sumhits = s->total_hits;
+ reclist_enter(se->reclist);
+ *total = reclist_get_num_records(se->reclist);
+ *sumhits = se->total_hits;
for (i = 0; i < start; i++)
- if (!reclist_read_record(s->reclist))
+ if (!reclist_read_record(se->reclist))
{
*num = 0;
recs = 0;
for (i = 0; i < *num; i++)
{
- struct record_cluster *r = reclist_read_record(s->reclist);
+ struct record_cluster *r = reclist_read_record(se->reclist);
if (!r)
{
*num = i;
}
recs[i] = r;
}
- reclist_leave(s->reclist);
+ reclist_leave(se->reclist);
}
#if USE_TIMING
yaz_timing_stop(t);
return recs;
}
-void show_range_stop(struct session *s, struct record_cluster **recs)
+void show_range_stop(struct session *se, struct record_cluster **recs)
{
- session_leave(s);
+ session_leave(se);
}
void statistics(struct session *se, struct statistics *stat)