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;
+
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));
void client_got_records(struct client *cl)
{
struct session *se = cl->session;
- if (se)
+
+ 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);
}
}
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;
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;