/* This file is part of Pazpar2.
- Copyright (C) 2006-2012 Index Data
+ Copyright (C) 2006-2013 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
enum client_state state;
struct show_raw *show_raw;
ZOOM_resultset resultset;
- YAZ_MUTEX mutex;
int ref_count;
char *id;
facet_limits_t facet_limits;
void client_check_preferred_watch(struct client *cl)
{
struct session *se = cl->session;
+
+ session_enter_ro(se, "client_check_preferred_watch");
yaz_log(YLOG_DEBUG, "client_check_preferred_watch: %s ", client_get_id(cl));
if (se)
{
- client_unlock(cl);
- /* TODO possible threading issue. Session can have been destroyed */
- if (session_is_preferred_clients_ready(se)) {
+ assert(cl->session);
+ if (session_is_preferred_clients_ready(se))
session_alert_watch(se, SESSION_WATCH_SHOW_PREF);
- }
else
yaz_log(YLOG_DEBUG, "client_check_preferred_watch: Still locked on preferred targets.");
-
- client_lock(cl);
+ assert(cl->session);
}
else
yaz_log(YLOG_WARN, "client_check_preferred_watch: %s. No session!", client_get_id(cl));
+ session_leave_ro(se, "client_check_preferred_watch");
}
struct suggestions* client_suggestions_create(const char* suggestions_string);
const char *error, *addinfo = 0;
+ session_enter_rw(cl->session, "client_search_response");
if (ZOOM_connection_error(link, &error, &addinfo))
{
cl->hits = 0;
client_suggestions_destroy(cl);
cl->suggestions = client_suggestions_create(ZOOM_resultset_option_get(resultset, "suggestions"));
}
+ session_leave_rw(cl->session, "client_search_response");
}
void client_got_records(struct client *cl)
{
struct session *se = cl->session;
- if (se)
+
+ session_enter_ro(se, "client_got_records");
+ if (reclist_get_num_records(se->reclist) > 0)
{
- if (reclist_get_num_records(se->reclist) > 0)
- {
- client_unlock(cl);
- session_alert_watch(se, SESSION_WATCH_SHOW);
- session_alert_watch(se, SESSION_WATCH_BYTARGET);
- session_alert_watch(se, SESSION_WATCH_TERMLIST);
- session_alert_watch(se, SESSION_WATCH_RECORD);
- client_lock(cl);
- }
+ session_alert_watch(se, SESSION_WATCH_SHOW);
+ session_alert_watch(se, SESSION_WATCH_BYTARGET);
+ session_alert_watch(se, SESSION_WATCH_TERMLIST);
+ session_alert_watch(se, SESSION_WATCH_RECORD);
}
+ session_leave_ro(se, "client_got_records");
}
static void client_record_ingest(struct client *cl)
ZOOM_resultset resultset = cl->resultset;
const char *error, *addinfo;
+ session_enter_rw(cl->session, "client_record_response");
if (ZOOM_connection_error(link, &error, &addinfo))
{
client_set_state(cl, Client_Error);
client_record_ingest(cl);
}
}
+ session_leave_rw(cl->session, "client_record_response");
}
int client_reingest(struct client *cl)
cl->show_raw = 0;
cl->resultset = 0;
cl->suggestions = 0;
- cl->mutex = 0;
- pazpar2_mutex_create(&cl->mutex, "client");
cl->preferred = 0;
cl->ref_count = 1;
cl->facet_limits = 0;
return cl;
}
-void client_lock(struct client *c)
-{
- yaz_mutex_enter(c->mutex);
-}
-
-void client_unlock(struct client *c)
-{
- yaz_mutex_leave(c->mutex);
-}
-
void client_incref(struct client *c)
{
- pazpar2_incref(&c->ref_count, c->mutex);
+ c->ref_count++;
yaz_log(YLOG_DEBUG, "client_incref c=%p %s cnt=%d",
c, client_get_id(c), c->ref_count);
}
{
yaz_log(YLOG_DEBUG, "client_destroy c=%p %s cnt=%d",
c, client_get_id(c), c->ref_count);
- if (!pazpar2_decref(&c->ref_count, c->mutex))
+ if (--c->ref_count == 0)
{
xfree(c->pquery);
c->pquery = 0;
{
ZOOM_resultset_destroy(c->resultset);
}
- yaz_mutex_destroy(&c->mutex);
xfree(c);
client_use(-1);
return 1;
static int apply_limit(struct session_database *sdb,
facet_limits_t facet_limits,
- WRBUF w_pqf, CCL_bibset ccl_map)
+ WRBUF w_pqf, CCL_bibset ccl_map,
+ struct conf_service *service)
{
int ret = 0;
int i = 0;
}
if (!s)
{
- yaz_log(YLOG_WARN, "Target %s: limit %s used, but no limitmap defined",
- (sdb->database ? sdb->database->id : "<no id>"), name);
+ int i;
+ for (i = 0; i < service->num_metadata; i++)
+ {
+ struct conf_metadata *md = service->metadata + i;
+ if (!strcmp(md->name, name) && md->limitcluster)
+ {
+ yaz_log(YLOG_LOG, "limitcluster in use for %s",
+ md->name);
+ break;
+ }
+ }
+ if (i == service->num_metadata)
+ {
+ yaz_log(YLOG_WARN, "Target %s: limit %s used, but no limitmap defined",
+ (sdb->database ? sdb->database->id : "<no id>"), name);
+ }
}
}
nmem_destroy(nmem_tmp);
// return -1 on query error
// return -2 on limit error
int client_parse_query(struct client *cl, const char *query,
- facet_limits_t facet_limits,
- CCL_bibset bibset)
+ facet_limits_t facet_limits)
{
struct session *se = client_get_session(cl);
+ struct conf_service *service = se->service;
struct session_database *sdb = client_get_database(cl);
struct ccl_rpn_node *cn;
int cerror, cpos;
ODR odr_out;
- CCL_bibset ccl_map = prepare_cclmap(cl, bibset);
+ CCL_bibset ccl_map = prepare_cclmap(cl, service->ccl_bibset);
const char *sru = session_setting_oneval(sdb, PZ_SRU);
const char *pqf_prefix = session_setting_oneval(sdb, PZ_PQF_PREFIX);
const char *pqf_strftime = session_setting_oneval(sdb, PZ_PQF_STRFTIME);
wrbuf_puts(w_pqf, " ");
}
- if (apply_limit(sdb, facet_limits, w_pqf, ccl_map))
+ if (apply_limit(sdb, facet_limits, w_pqf, ccl_map, service))
{
ccl_qual_rm(&ccl_map);
return -2;
return cl->maxrecs;
}
-void client_set_preferred(struct client *cl, int v)
-{
- cl->preferred = v;
-}
-
-
struct suggestions* client_suggestions_create(const char* suggestions_string)
{
int i;