From f3400ec3934bfbe1b7e9715a949e107ad9362324 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 6 Oct 2011 12:45:01 +0200 Subject: [PATCH] Rename client_get_url to client_get_id --- src/client.c | 45 +++++++++++++++++++++++---------------------- src/client.h | 2 +- src/connection.c | 14 +++++++------- src/http_command.c | 2 +- src/session.c | 4 ++-- 5 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/client.c b/src/client.c index b650273..825d900 100644 --- a/src/client.c +++ b/src/client.c @@ -119,7 +119,7 @@ struct client { ZOOM_resultset resultset; YAZ_MUTEX mutex; int ref_count; - char *url; + char *id; }; struct show_raw { @@ -166,7 +166,8 @@ void client_set_state(struct client *cl, enum client_state st) { 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); @@ -346,7 +347,7 @@ static void client_send_raw_present(struct client *cl) 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; @@ -483,7 +484,7 @@ static void ingest_raw_record(struct client *cl, ZOOM_record rec) 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); @@ -497,7 +498,7 @@ void client_check_preferred_watch(struct client *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)); } @@ -515,7 +516,7 @@ void client_search_response(struct client *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 { @@ -555,7 +556,7 @@ void client_record_response(struct client *cl) { 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 { @@ -587,7 +588,7 @@ void client_record_response(struct client *cl) 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 @@ -602,12 +603,12 @@ void client_record_response(struct client *cl) 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); } @@ -694,7 +695,7 @@ void client_start_search(struct client *cl) 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); @@ -735,7 +736,7 @@ void client_start_search(struct client *cl) 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) @@ -745,7 +746,7 @@ void client_start_search(struct client *cl) } 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); @@ -753,7 +754,7 @@ void client_start_search(struct client *cl) 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; @@ -773,8 +774,8 @@ struct client *client_create(const char *url) 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; @@ -794,7 +795,7 @@ void client_incref(struct client *c) { 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) @@ -802,14 +803,14 @@ 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) @@ -1039,7 +1040,7 @@ int client_parse_query(struct client *cl, const char *query, 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; @@ -1153,9 +1154,9 @@ void client_set_database(struct client *cl, struct session_database *db) 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) diff --git a/src/client.h b/src/client.h index f037a04..743a509 100644 --- a/src/client.h +++ b/src/client.h @@ -89,7 +89,7 @@ int client_get_num_records(struct client *cl); int client_get_diagnostic(struct client *cl); void client_set_diagnostic(struct client *cl, int diagnostic); void client_set_database(struct client *cl, struct session_database *db); -const char *client_get_url(struct client *cl); +const char *client_get_id(struct client *cl); void client_set_maxrecs(struct client *cl, int v); int client_get_maxrecs(struct client *cl); void client_set_startrecs(struct client *cl, int v); diff --git a/src/connection.c b/src/connection.c index 4c69f49..9381b53 100644 --- a/src/connection.c +++ b/src/connection.c @@ -223,7 +223,7 @@ static void non_block_events(struct connection *co) 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); } @@ -248,7 +248,7 @@ static void non_block_events(struct connection *co) 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: @@ -260,7 +260,7 @@ static void non_block_events(struct connection *co) break; default: yaz_log(YLOG_LOG, "Unhandled event (%d) from %s", - ev, client_get_url(cl)); + ev, client_get_id(cl)); } } if (got_records) @@ -305,7 +305,7 @@ static void connection_handler(IOCHAN iochan, int event) { 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); @@ -314,7 +314,7 @@ static void connection_handler(IOCHAN iochan, int event) } 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); @@ -449,7 +449,7 @@ int client_prep_connection(struct client *cl, 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); @@ -519,7 +519,7 @@ int client_prep_connection(struct client *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; diff --git a/src/http_command.c b/src/http_command.c index a4f7405..088a502 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -696,7 +696,7 @@ static void write_subrecord(struct record *r, WRBUF w, client_get_database(r->client), PZ_NAME); wrbuf_puts(w, "client)); + wrbuf_xmlputs(w, client_get_id(r->client)); wrbuf_puts(w, "\" "); wrbuf_puts(w, "name=\""); diff --git a/src/session.c b/src/session.c index 202c5dd..9614f15 100644 --- a/src/session.c +++ b/src/session.c @@ -855,7 +855,7 @@ static struct hitsbytarget *hitsbytarget_nb(struct session *se, const char *name = session_setting_oneval(client_get_database(cl), PZ_NAME); - res[*count].id = client_get_url(cl); + res[*count].id = client_get_id(cl); res[*count].name = *name ? name : "Unknown"; res[*count].hits = client_get_hits(cl); res[*count].records = client_get_num_records(cl); @@ -1305,7 +1305,7 @@ static const char *get_mergekey(xmlDoc *doc, struct client *cl, int record_no, if (wrbuf_len(norm_wr) == 0) { wrbuf_printf(norm_wr, "%s-%d", - client_get_url(cl), record_no); + client_get_id(cl), record_no); } if (wrbuf_len(norm_wr) > 0) mergekey_norm = nmem_strdup(nmem, wrbuf_cstr(norm_wr)); -- 1.7.10.4