|
pazpar2
1.6.30
|
Z39.50 client. More...
#include <stdlib.h>#include <stdio.h>#include <string.h>#include <signal.h>#include <assert.h>#include <yaz/marcdisp.h>#include <yaz/comstack.h>#include <yaz/tcpip.h>#include <yaz/proto.h>#include <yaz/readconf.h>#include <yaz/pquery.h>#include <yaz/otherinfo.h>#include <yaz/yaz-util.h>#include <yaz/nmem.h>#include <yaz/query-charset.h>#include <yaz/querytowrbuf.h>#include <yaz/oid_db.h>#include <yaz/diagbib1.h>#include <yaz/snprintf.h>#include <yaz/rpn2cql.h>#include <yaz/rpn2solr.h>#include <yaz/gettimeofday.h>#include "ppmutex.h"#include "session.h"#include "parameters.h"#include "client.h"#include "connection.h"#include "settings.h"#include "relevance.h"#include "incref.h"Go to the source code of this file.
Data Structures | |
| struct | client |
| Represents client state for a connection to one search target. More... | |
| struct | suggestions |
| struct | show_raw |
Macros | |
| #define | USE_TIMING 0 |
Functions | |
| static int | client_use (int delta) |
| int | clients_count (void) |
| int | clients_count_total (void) |
| const char * | client_get_state_str (struct client *cl) |
| enum client_state | client_get_state (struct client *cl) |
| void | client_set_state_nb (struct client *cl, enum client_state st) |
| void | client_set_state (struct client *cl, enum client_state st) |
| static void | client_show_raw_error (struct client *cl, const char *addinfo) |
| struct connection * | client_get_connection (struct client *cl) |
| struct session_database * | client_get_database (struct client *cl) |
| struct session * | client_get_session (struct client *cl) |
| static void | client_send_raw_present (struct client *cl) |
| static int | nativesyntax_to_type (const char *s, char *type, ZOOM_record rec) |
| static void | client_show_immediate (ZOOM_resultset resultset, struct session_database *sdb, int position, void *data, void(*error_handler)(void *data, const char *addinfo), void(*record_handler)(void *data, const char *buf, size_t sz), int binary, const char *nativesyntax) |
| int | client_show_raw_begin (struct client *cl, int position, const char *syntax, const char *esn, void *data, void(*error_handler)(void *data, const char *addinfo), void(*record_handler)(void *data, const char *buf, size_t sz), int binary, const char *nativesyntax) |
| static void | client_show_raw_delete (struct show_raw *r) |
| void | client_show_raw_remove (struct client *cl, void *data) |
| static void | client_show_raw_dequeue (struct client *cl) |
| static void | client_report_facets (struct client *cl, ZOOM_resultset rs) |
| static void | ingest_raw_record (struct client *cl, ZOOM_record rec) |
| void | client_check_preferred_watch (struct client *cl) |
| struct suggestions * | client_suggestions_create (const char *suggestions_string) |
| static void | client_suggestions_destroy (struct client *cl) |
| void | client_search_response (struct client *cl) |
| void | client_got_records (struct client *cl) |
| static void | client_record_ingest (struct client *cl) |
| void | client_record_response (struct client *cl, int *got_records) |
| int | client_reingest (struct client *cl) |
| static void | client_set_facets_request (struct client *cl, ZOOM_connection link) |
| int | client_has_facet (struct client *cl, const char *name) |
| static const char * | get_strategy_plus_sort (struct client *l, const char *field) |
| void | client_update_show_stat (struct client *cl, int cmd) |
| int | client_fetch_more (struct client *cl) |
| int | client_parse_init (struct client *cl, int same_search) |
| int | client_parse_range (struct client *cl, const char *startrecs, const char *maxrecs) |
| int | client_start_search (struct client *cl) |
| struct client * | client_create (const char *id) |
| void | client_lock (struct client *c) |
| void | client_unlock (struct client *c) |
| void | client_incref (struct client *c) |
| int | client_destroy (struct client *c) |
| void | client_set_connection (struct client *cl, struct connection *con) |
| void | client_disconnect (struct client *cl) |
| static CCL_bibset | prepare_cclmap (struct client *cl, CCL_bibset base_bibset) |
| static char * | make_cqlquery (struct client *cl, Z_RPNQuery *zquery) |
| static char * | make_solrquery (struct client *cl, Z_RPNQuery *zquery) |
| const char * | client_get_facet_limit_local (struct client *cl, struct session_database *sdb, int *l, NMEM nmem, int *num, char ***values) |
| static int | apply_limit (struct session_database *sdb, facet_limits_t facet_limits, WRBUF w_pqf, CCL_bibset ccl_map, struct conf_service *service) |
| int | client_parse_query (struct client *cl, const char *query, facet_limits_t facet_limits) |
| int | client_parse_sort (struct client *cl, struct reclist_sortparms *sp) |
| void | client_set_session (struct client *cl, struct session *se) |
| int | client_is_active (struct client *cl) |
| int | client_is_active_preferred (struct client *cl) |
| Odr_int | client_get_hits (struct client *cl) |
| Odr_int | client_get_approximation (struct client *cl) |
| int | client_get_num_records (struct client *cl) |
| int | client_get_num_records_filtered (struct client *cl) |
| void | client_set_diagnostic (struct client *cl, int diagnostic, const char *message, const char *addinfo) |
| int | client_get_diagnostic (struct client *cl, const char **message, const char **addinfo) |
| const char * | client_get_suggestions_xml (struct client *cl, WRBUF wrbuf) |
| void | client_set_database (struct client *cl, struct session_database *db) |
| const char * | client_get_id (struct client *cl) |
| int | client_get_maxrecs (struct client *cl) |
| void | client_set_preferred (struct client *cl, int v) |
Variables | |
| static YAZ_MUTEX | g_mutex = 0 |
| static int | no_clients = 0 |
| static int | no_clients_total = 0 |
| static const char * | client_states [] |
Z39.50 client.
Definition in file client.c.
|
static |
Definition at line 1232 of file client.c.
References session_database::database, facet_limits_get(), database::id, conf_metadata::limitcluster, conf_service::metadata, setting::name, conf_metadata::name, name, setting::next, conf_service::num_metadata, PZ_LIMITMAP, session_database::settings, and setting::value.
Referenced by client_parse_query().
| void client_check_preferred_watch | ( | struct client * | cl | ) |
Definition at line 512 of file client.c.
References client_get_id(), client_lock(), client_unlock(), client::session, session_alert_watch(), session_is_preferred_clients_ready(), and SESSION_WATCH_SHOW_PREF.
Referenced by non_block_events().
|
read |
Definition at line 987 of file client.c.
References client::addinfo, Client_Disconnected, client_use(), client::connection, client::cqlquery, client::database, client::diagnostic, client::facet_limits, client::filtered, client::hits, client::id, client::maxrecs, client::message, client::mutex, pazpar2_mutex_create(), client::pquery, client::preferred, client::record_offset, client::ref_count, client::resultset, client::session, client::show_raw, client::sort_criteria, client::sort_strategy, client::startrecs, client::state, and client::suggestions.
Referenced by select_targets_callback().
| int client_destroy | ( | struct client * | c | ) |
Definition at line 1038 of file client.c.
References client::addinfo, client_get_id(), client_use(), client::connection, client::cqlquery, client::facet_limits, facet_limits_destroy(), client::id, client::message, client::mutex, pazpar2_decref(), client::pquery, client::ref_count, client::resultset, client::sort_criteria, and client::sort_strategy.
Referenced by client_set_connection(), and session_remove_cached_clients().
| void client_disconnect | ( | struct client * | cl | ) |
Definition at line 1090 of file client.c.
References Client_Disconnected, Client_Idle, client_set_connection(), client_set_state(), and client::state.
Referenced by connection_destroy().
| int client_fetch_more | ( | struct client * | cl | ) |
Definition at line 775 of file client.c.
References client_get_connection(), client_get_database(), client_get_id(), client_set_state(), Client_Working, connection_continue(), client::hits, PZ_ELEMENTS, PZ_EXTENDRECS, PZ_REQUESTSYNTAX, client::record_offset, client::resultset, session_setting_oneval(), and client::show_stat_no.
Referenced by session_fetch_more().
| Odr_int client_get_approximation | ( | struct client * | cl | ) |
Definition at line 1587 of file client.c.
References client_get_id(), client::filtered, client::hits, and client::record_offset.
Referenced by hitsbytarget_nb(), and show_range_start().
|
read |
Definition at line 212 of file client.c.
References client::connection.
Referenced by client_fetch_more(), client_prep_connection(), client_send_raw_present(), client_start_search(), hitsbytarget_nb(), and statistics().
|
read |
Definition at line 217 of file client.c.
References client::database.
Referenced by check_limit_local(), client_fetch_more(), client_has_facet(), client_parse_query(), client_prep_connection(), client_record_ingest(), client_report_facets(), client_send_raw_present(), client_set_facets_request(), client_show_raw_begin(), client_start_search(), connection_connect(), get_strategy_plus_sort(), hitsbytarget_nb(), ingest_record(), ingest_to_cluster(), prepare_cclmap(), select_targets_callback(), session_search(), and write_subrecord().
| int client_get_diagnostic | ( | struct client * | cl, |
| const char ** | message, | ||
| const char ** | addinfo | ||
| ) |
Definition at line 1623 of file client.c.
References client::addinfo, client::diagnostic, and client::message.
Referenced by hitsbytarget_nb().
| const char* client_get_facet_limit_local | ( | struct client * | cl, |
| struct session_database * | sdb, | ||
| int * | l, | ||
| NMEM | nmem, | ||
| int * | num, | ||
| char *** | values | ||
| ) |
Definition at line 1190 of file client.c.
References client::facet_limits, facet_limits_get(), setting::name, name, setting::next, PZ_LIMITMAP, session_database::settings, and setting::value.
Referenced by check_limit_local().
| Odr_int client_get_hits | ( | struct client * | cl | ) |
Definition at line 1582 of file client.c.
References client::hits.
Referenced by hitsbytarget_nb(), ingest_to_cluster(), show_range_start(), and statistics().
| const char* client_get_id | ( | struct client * | cl | ) |
Definition at line 1668 of file client.c.
References client::id.
Referenced by client_check_preferred_watch(), client_destroy(), client_fetch_more(), client_get_approximation(), client_incref(), client_parse_query(), client_parse_sort(), client_prep_connection(), client_record_ingest(), client_record_response(), client_search_response(), client_send_raw_present(), client_set_state(), client_start_search(), get_mergekey(), hitsbytarget_nb(), non_block_events(), prepare_cclmap(), record_create(), session_fetch_more(), session_sort_unlocked(), and write_subrecord().
| int client_get_maxrecs | ( | struct client * | cl | ) |
Definition at line 1673 of file client.c.
References client::maxrecs.
Referenced by ingest_to_cluster().
| int client_get_num_records | ( | struct client * | cl | ) |
Definition at line 1601 of file client.c.
References client::record_offset.
Referenced by hitsbytarget_nb().
| int client_get_num_records_filtered | ( | struct client * | cl | ) |
Definition at line 1606 of file client.c.
References client::filtered.
Referenced by hitsbytarget_nb().
Definition at line 222 of file client.c.
References client::session.
Referenced by check_limit_local(), client_parse_query(), client_prep_connection(), client_record_ingest(), client_report_facets(), client_start_search(), ingest_record(), and ingest_to_cluster().
| enum client_state client_get_state | ( | struct client * | cl | ) |
Definition at line 176 of file client.c.
References client::state.
Referenced by client_prep_connection(), session_fetch_more(), session_sort_unlocked(), and statistics().
| const char* client_get_state_str | ( | struct client * | cl | ) |
Definition at line 171 of file client.c.
References client_states, and client::state.
Referenced by hitsbytarget_nb(), and session_fetch_more().
| const char* client_get_suggestions_xml | ( | struct client * | cl, |
| WRBUF | wrbuf | ||
| ) |
Definition at line 1633 of file client.c.
References suggestions::num, suggestions::passthrough, and client::suggestions.
Referenced by hitsbytarget_nb().
| void client_got_records | ( | struct client * | cl | ) |
Definition at line 566 of file client.c.
References client_lock(), client_unlock(), session::reclist, reclist_get_num_records(), client::session, session_alert_watch(), SESSION_WATCH_BYTARGET, SESSION_WATCH_RECORD, SESSION_WATCH_SHOW, and SESSION_WATCH_TERMLIST.
Referenced by non_block_events().
| int client_has_facet | ( | struct client * | cl, |
| const char * | name | ||
| ) |
Definition at line 728 of file client.c.
References client_get_database(), setting::name, setting::next, PZ_FACETMAP, and session_database::settings.
Referenced by ingest_to_cluster().
| void client_incref | ( | struct client * | c | ) |
Definition at line 1031 of file client.c.
References client_get_id(), client::mutex, pazpar2_incref(), and client::ref_count.
Referenced by client_prep_connection(), and client_set_connection().
| int client_is_active | ( | struct client * | cl | ) |
Definition at line 1562 of file client.c.
References Client_Connecting, Client_Working, client::connection, and client::state.
Referenced by client_set_state(), and session_active_clients().
| int client_is_active_preferred | ( | struct client * | cl | ) |
Definition at line 1570 of file client.c.
References Client_Connecting, Client_Working, client::connection, client::preferred, and client::state.
Referenced by session_is_preferred_clients_ready().
| void client_lock | ( | struct client * | c | ) |
Definition at line 1021 of file client.c.
References client::mutex.
Referenced by client_check_preferred_watch(), client_got_records(), connection_handler(), session_remove_cached_clients(), and session_reset_active_clients().
| int client_parse_init | ( | struct client * | cl, |
| int | same_search | ||
| ) |
Definition at line 819 of file client.c.
References client::same_search.
Referenced by session_search(), and session_sort_unlocked().
| int client_parse_query | ( | struct client * | cl, |
| const char * | query, | ||
| facet_limits_t | facet_limits | ||
| ) |
Definition at line 1357 of file client.c.
References apply_limit(), conf_service::ccl_bibset, conf_service::charsets, Client_Error, client_get_database(), client_get_id(), client_get_session(), client_set_state(), client::cqlquery, client::facet_limits, facet_limits_destroy(), facet_limits_dup(), make_cqlquery(), make_solrquery(), client::pquery, prepare_cclmap(), PZ_PQF_PREFIX, PZ_PQF_STRFTIME, PZ_QUERY_SYNTAX, PZ_SRU, conf_service::rank_cluster, conf_service::rank_follow, conf_service::rank_lead, conf_service::rank_length, session::relevance, relevance_create_ccl(), client::same_search, session::service, session_log(), and session_setting_oneval().
Referenced by session_search().
| int client_parse_range | ( | struct client * | cl, |
| const char * | startrecs, | ||
| const char * | maxrecs | ||
| ) |
Definition at line 828 of file client.c.
References client::maxrecs, client::same_search, and client::startrecs.
Referenced by session_search().
| int client_parse_sort | ( | struct client * | cl, |
| struct reclist_sortparms * | sp | ||
| ) |
Definition at line 1497 of file client.c.
References client_get_id(), get_strategy_plus_sort(), reclist_sortparms::increasing, reclist_sortparms::name, client::same_search, client::sort_criteria, and client::sort_strategy.
Referenced by session_search(), and session_sort_unlocked().
|
static |
Definition at line 583 of file client.c.
References client_get_database(), client_get_id(), client_get_session(), client::filtered, ingest_record(), nativesyntax_to_type(), PZ_NATIVESYNTAX, client::record_offset, client::resultset, client::session, session_log(), and session_setting_oneval().
Referenced by client_record_response(), and client_reingest().
| void client_record_response | ( | struct client * | cl, |
| int * | got_records | ||
| ) |
Definition at line 649 of file client.c.
References show_raw::active, Client_Error, client_get_id(), client_record_ingest(), client_set_state(), client::connection, connection_get_link(), error(), ingest_raw_record(), connection::link, show_raw::position, client::resultset, and client::show_raw.
Referenced by non_block_events().
| int client_reingest | ( | struct client * | cl | ) |
Definition at line 687 of file client.c.
References client_record_ingest(), client::filtered, client::record_offset, and client::startrecs.
Referenced by client_start_search().
|
static |
TODO Consider thread safety!!!
Definition at line 456 of file client.c.
References add_facet(), client_get_database(), client_get_session(), setting::name, setting::next, PZ_FACETMAP, session_database::settings, and setting::value.
Referenced by client_search_response().
| void client_search_response | ( | struct client * | cl | ) |
Definition at line 536 of file client.c.
References Client_Error, client_get_id(), client_report_facets(), client_set_state(), client_suggestions_create(), client_suggestions_destroy(), client::connection, connection_get_link(), error(), client::hits, connection::link, client::record_offset, client::resultset, client::startrecs, and client::suggestions.
Referenced by non_block_events().
|
static |
Definition at line 377 of file client.c.
References show_raw::active, client_get_connection(), client_get_database(), client_get_id(), connection_continue(), show_raw::esn, show_raw::position, PZ_ELEMENTS, PZ_REQUESTSYNTAX, client::resultset, session_setting_oneval(), client::show_raw, and show_raw::syntax.
Referenced by client_show_raw_begin().
| void client_set_connection | ( | struct client * | cl, |
| struct connection * | con | ||
| ) |
Definition at line 1073 of file client.c.
References client_destroy(), client_incref(), client::connection, and client::resultset.
Referenced by client_disconnect(), client_prep_connection(), connection_create(), and connection_release().
| void client_set_database | ( | struct client * | cl, |
| struct session_database * | db | ||
| ) |
Definition at line 1663 of file client.c.
References client::database.
Referenced by select_targets_callback(), and session_remove_cached_clients().
| void client_set_diagnostic | ( | struct client * | cl, |
| int | diagnostic, | ||
| const char * | message, | ||
| const char * | addinfo | ||
| ) |
Definition at line 1611 of file client.c.
References client::addinfo, client::diagnostic, and client::message.
Referenced by non_block_events(), and prepare_cclmap().
|
static |
Definition at line 699 of file client.c.
References client_get_database(), setting::name, setting::next, PZ_FACETMAP, session_database::settings, and setting::value.
Referenced by client_start_search().
| void client_set_preferred | ( | struct client * | cl, |
| int | v | ||
| ) |
Definition at line 1678 of file client.c.
References client::preferred.
Definition at line 1557 of file client.c.
References client::session.
Referenced by select_targets_callback(), session_remove_cached_clients(), and session_reset_active_clients().
| void client_set_state | ( | struct client * | cl, |
| enum client_state | st | ||
| ) |
Definition at line 186 of file client.c.
References client_get_id(), client_is_active(), client::session, session_active_clients(), session_alert_watch(), SESSION_WATCH_BYTARGET, SESSION_WATCH_SHOW, SESSION_WATCH_SHOW_PREF, SESSION_WATCH_TERMLIST, and client::state.
Referenced by client_disconnect(), client_fetch_more(), client_parse_query(), client_prep_connection(), client_record_response(), client_search_response(), client_start_search(), connection_connect(), and non_block_events().
| void client_set_state_nb | ( | struct client * | cl, |
| enum client_state | st | ||
| ) |
|
static |
Definition at line 230 of file client.c.
References nativesyntax_to_type().
Referenced by client_show_raw_begin().
| int client_show_raw_begin | ( | struct client * | cl, |
| int | position, | ||
| const char * | syntax, | ||
| const char * | esn, | ||
| void * | data, | ||
| void(*)(void *data, const char *addinfo) | error_handler, | ||
| void(*)(void *data, const char *buf, size_t sz) | record_handler, | ||
| int | binary, | ||
| const char * | nativesyntax | ||
| ) |
Definition at line 265 of file client.c.
References show_raw::active, show_raw::binary, Client_Disconnected, Client_Failed, client_get_database(), client_send_raw_present(), client_show_immediate(), client_show_raw_error(), client::connection, show_raw::data, show_raw::error_handler, show_raw::esn, show_raw::nativesyntax, show_raw::next, show_raw::position, PZ_NATIVESYNTAX, show_raw::record_handler, client::resultset, session_setting_oneval(), client::show_raw, client::state, and show_raw::syntax.
Referenced by show_record().
|
static |
Definition at line 339 of file client.c.
References show_raw::esn, show_raw::nativesyntax, and show_raw::syntax.
Referenced by client_show_raw_dequeue(), and client_show_raw_remove().
|
static |
Definition at line 360 of file client.c.
References client_show_raw_delete(), show_raw::next, and client::show_raw.
Referenced by client_show_raw_error(), and ingest_raw_record().
|
static |
Definition at line 368 of file client.c.
References client_show_raw_dequeue(), show_raw::data, show_raw::error_handler, and client::show_raw.
Referenced by client_show_raw_begin().
| void client_show_raw_remove | ( | struct client * | cl, |
| void * | data | ||
| ) |
Definition at line 347 of file client.c.
References client_show_raw_delete(), show_raw::data, show_raw::next, and client::show_raw.
| int client_start_search | ( | struct client * | cl | ) |
Definition at line 846 of file client.c.
References client_get_connection(), client_get_database(), client_get_id(), client_get_session(), client_prep_connection(), client_reingest(), client_set_facets_request(), client_set_state(), Client_Working, connection_continue(), connection_get_link(), client::cqlquery, client::diagnostic, client::filtered, client::hits, conf_server::iochan_man, connection::link, client::maxrecs, client::pquery, client::preferred, PZ_ELEMENTS, PZ_EXTRA_ARGS, PZ_MAXRECS, PZ_PIGGYBACK, PZ_PREFERRED, PZ_PRESENT_CHUNK, PZ_QUERYENCODING, PZ_REQUESTSYNTAX, PZ_SORT, PZ_SRU, client::record_offset, client::resultset, client::same_search, conf_service::server, session::service, session_log(), session_setting_oneval(), client::sort_criteria, client::sort_strategy, client::startrecs, conf_service::z3950_operation_timeout, and conf_service::z3950_session_timeout.
Referenced by connect_resolver_host(), session_search(), and session_sort_unlocked().
|
read |
Definition at line 1684 of file client.c.
References suggestions::misspelled, suggestions::nmem, suggestions::num, suggestions::passthrough, and suggestions::suggest.
Referenced by client_search_response().
|
static |
Definition at line 1719 of file client.c.
References suggestions::nmem, and client::suggestions.
Referenced by client_search_response().
| void client_unlock | ( | struct client * | c | ) |
Definition at line 1026 of file client.c.
References client::mutex.
Referenced by client_check_preferred_watch(), client_got_records(), connection_handler(), session_remove_cached_clients(), and session_reset_active_clients().
| void client_update_show_stat | ( | struct client * | cl, |
| int | cmd | ||
| ) |
Definition at line 767 of file client.c.
References client::show_stat_no.
Referenced by show_range_start().
|
static |
Definition at line 78 of file client.c.
References g_mutex, no_clients, and no_clients_total.
Referenced by client_create(), client_destroy(), and clients_count().
| int clients_count | ( | void | ) |
| int clients_count_total | ( | void | ) |
Definition at line 99 of file client.c.
References g_mutex, and no_clients_total.
|
static |
Definition at line 742 of file client.c.
References client_get_database(), setting::name, setting::next, PZ_SORTMAP, session_database::settings, and setting::value.
Referenced by client_parse_sort().
|
static |
Definition at line 500 of file client.c.
References client_show_raw_dequeue(), show_raw::data, show_raw::nativesyntax, nativesyntax_to_type(), show_raw::record_handler, and client::show_raw.
Referenced by client_record_response().
|
static |
Definition at line 1148 of file client.c.
Referenced by client_parse_query().
|
static |
Definition at line 1170 of file client.c.
Referenced by client_parse_query().
|
static |
Definition at line 412 of file client.c.
Referenced by client_record_ingest(), client_show_immediate(), and ingest_raw_record().
|
static |
Definition at line 1098 of file client.c.
References Client_Error, client_get_database(), client_get_id(), client_set_diagnostic(), client_set_state_nb(), setting::name, setting::next, PZ_CCLMAP, session_database::settings, and setting::value.
Referenced by client_parse_query().
|
static |
Definition at line 162 of file client.c.
Referenced by client_get_state_str().
|
static |
Definition at line 74 of file client.c.
Referenced by client_use(), and clients_count_total().
|
static |
Definition at line 75 of file client.c.
Referenced by client_use().
|
static |
Definition at line 76 of file client.c.
Referenced by client_use(), and clients_count_total().
1.8.1.2