ZOOM_resultset resultset;
YAZ_MUTEX mutex;
int ref_count;
- char *url;
+ char *id;
};
struct show_raw {
{
int no_active = session_active_clients(cl->session);
- yaz_log(YLOG_DEBUG, "%s: releasing watches on zero active: %d", client_get_url(cl), no_active);
+ yaz_log(YLOG_DEBUG, "%s: releasing watches on zero active: %d",
+ client_get_id(cl), no_active);
if (no_active == 0) {
session_alert_watch(cl->session, SESSION_WATCH_SHOW);
session_alert_watch(cl->session, SESSION_WATCH_SHOW_PREF);
assert(set);
yaz_log(YLOG_DEBUG, "%s: trying to present %d record(s) from %d",
- client_get_url(cl), 1, offset);
+ client_get_id(cl), 1, offset);
if (cl->show_raw->syntax)
syntax = cl->show_raw->syntax;
void client_check_preferred_watch(struct client *cl)
{
struct session *se = cl->session;
- yaz_log(YLOG_DEBUG, "client_check_preferred_watch: %s ", client_get_url(cl));
+ yaz_log(YLOG_DEBUG, "client_check_preferred_watch: %s ", client_get_id(cl));
if (se)
{
client_unlock(cl);
client_lock(cl);
}
else
- yaz_log(YLOG_WARN, "client_check_preferred_watch: %s. No session!", client_get_url(cl));
+ yaz_log(YLOG_WARN, "client_check_preferred_watch: %s. No session!", client_get_id(cl));
}
cl->hits = 0;
client_set_state(cl, Client_Error);
yaz_log(YLOG_WARN, "Search error %s (%s): %s",
- error, addinfo, client_get_url(cl));
+ error, addinfo, client_get_id(cl));
}
else
{
{
client_set_state(cl, Client_Error);
yaz_log(YLOG_WARN, "Search error %s (%s): %s",
- error, addinfo, client_get_url(cl));
+ error, addinfo, client_get_id(cl));
}
else
{
else if (ZOOM_record_error(rec, &msg, &addinfo, 0))
{
yaz_log(YLOG_WARN, "Record error %s (%s): %s (rec #%d)",
- msg, addinfo, client_get_url(cl),
+ msg, addinfo, client_get_id(cl),
cl->record_offset);
}
else
xmlrec = ZOOM_record_get(rec, type, NULL);
if (!xmlrec)
yaz_log(YLOG_WARN, "ZOOM_record_get failed from %s",
- client_get_url(cl));
+ client_get_id(cl));
else
{
/* OK = 0, -1 = failure, -2 = Filtered */
if (ingest_record(cl, xmlrec, cl->record_offset, nmem) == -1)
- yaz_log(YLOG_WARN, "Failed to ingest from %s", client_get_url(cl));
+ yaz_log(YLOG_WARN, "Failed to ingest from %s", client_get_id(cl));
}
nmem_destroy(nmem);
}
cl->preferred = atoi(opt_preferred);
if (cl->preferred)
yaz_log(YLOG_LOG, "Target %s has preferred status: %d",
- client_get_url(cl), cl->preferred);
+ client_get_id(cl), cl->preferred);
}
client_set_state(cl, Client_Working);
if (cl->cqlquery)
{
ZOOM_query q = ZOOM_query_create();
- yaz_log(YLOG_LOG, "Search %s CQL: %s", client_get_url(cl),
+ yaz_log(YLOG_LOG, "Search %s CQL: %s", client_get_id(cl),
cl->cqlquery);
ZOOM_query_cql(q, cl->cqlquery);
if (*opt_sort)
}
else
{
- yaz_log(YLOG_LOG, "Search %s PQF: %s", client_get_url(cl), cl->pquery);
+ yaz_log(YLOG_LOG, "Search %s PQF: %s", client_get_id(cl), cl->pquery);
rs = ZOOM_connection_search_pqf(link, cl->pquery);
}
ZOOM_resultset_destroy(cl->resultset);
connection_continue(co);
}
-struct client *client_create(const char *url)
+struct client *client_create(const char *id)
{
struct client *cl = xmalloc(sizeof(*cl));
cl->maxrecs = 100;
pazpar2_mutex_create(&cl->mutex, "client");
cl->preferred = 0;
cl->ref_count = 1;
- assert(url);
- cl->url = xstrdup(url);
+ assert(id);
+ cl->id = xstrdup(id);
client_use(1);
return cl;
{
pazpar2_incref(&c->ref_count, c->mutex);
yaz_log(YLOG_DEBUG, "client_incref c=%p %s cnt=%d",
- c, client_get_url(c), c->ref_count);
+ c, client_get_id(c), c->ref_count);
}
int client_destroy(struct client *c)
if (c)
{
yaz_log(YLOG_DEBUG, "client_destroy c=%p %s cnt=%d",
- c, client_get_url(c), c->ref_count);
+ c, client_get_id(c), c->ref_count);
if (!pazpar2_decref(&c->ref_count, c->mutex))
{
xfree(c->pquery);
c->pquery = 0;
xfree(c->cqlquery);
c->cqlquery = 0;
- xfree(c->url);
+ xfree(c->id);
assert(!c->connection);
if (c->resultset)
client_set_state(cl, Client_Error);
session_log(se, YLOG_WARN, "Failed to parse CCL query '%s' for %s",
wrbuf_cstr(w_ccl),
- client_get_url(cl));
+ client_get_id(cl));
wrbuf_destroy(w_ccl);
wrbuf_destroy(w_pqf);
return -1;
cl->database = db;
}
-const char *client_get_url(struct client *cl)
+const char *client_get_id(struct client *cl)
{
- return cl->url;
+ return cl->id;
}
void client_set_maxrecs(struct client *cl, int v)
if ((err = ZOOM_connection_error(link, &error, &addinfo)))
{
yaz_log(YLOG_LOG, "Error %s from %s",
- error, client_get_url(cl));
+ error, client_get_id(cl));
client_set_diagnostic(cl, err);
client_set_state(cl, Client_Error);
}
case ZOOM_EVENT_RECV_APDU:
break;
case ZOOM_EVENT_CONNECT:
- yaz_log(YLOG_LOG, "Connected to %s", client_get_url(cl));
+ yaz_log(YLOG_LOG, "Connected to %s", client_get_id(cl));
co->state = Conn_Open;
break;
case ZOOM_EVENT_RECV_SEARCH:
break;
default:
yaz_log(YLOG_LOG, "Unhandled event (%d) from %s",
- ev, client_get_url(cl));
+ ev, client_get_id(cl));
}
}
if (got_records)
{
if (co->state == Conn_Connecting)
{
- yaz_log(YLOG_WARN, "%p connect timeout %s", co, client_get_url(cl));
+ yaz_log(YLOG_WARN, "%p connect timeout %s", co, client_get_id(cl));
client_set_state(cl, Client_Error);
remove_connection_from_host(co);
}
else
{
- yaz_log(YLOG_LOG, "%p Connection idle timeout %s", co, client_get_url(cl));
+ yaz_log(YLOG_LOG, "%p Connection idle timeout %s", co, client_get_id(cl));
remove_connection_from_host(co);
yaz_mutex_leave(host->mutex);
connection_destroy(co);
url);
yaz_log(YLOG_DEBUG, "client_prep_connection: target=%s url=%s",
- client_get_url(cl), url);
+ client_get_id(cl), url);
co = client_get_connection(cl);
num_connections, max_connections);
if (yaz_cond_wait(host->cond_ready, host->mutex, abstime))
{
- yaz_log(YLOG_LOG, "out of connections %s", client_get_url(cl));
+ yaz_log(YLOG_LOG, "out of connections %s", client_get_id(cl));
client_set_state(cl, Client_Error);
yaz_mutex_leave(host->mutex);
return 0;