pazpar2
1.14.1
|
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <yaz/snprintf.h>
#include <yaz/yaz-util.h>
#include <yaz/malloc_info.h>
#include "ppmutex.h"
#include "eventl.h"
#include "parameters.h"
#include "session.h"
#include "http.h"
#include "settings.h"
#include "client.h"
Go to the source code of this file.
Data Structures | |
struct | http_session |
struct | http_sessions |
Macros | |
#define | PAZPAR2_PROTOCOL_VERSION "1" |
#define | HTTP_COMMAND_RESPONSE_PREFIX "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" |
Functions | |
static void | show_records_ready (void *data) |
int | get_version (struct http_request *rq) |
int | http_session_use (int delta) |
http_sessions_t | http_sessions_create (void) |
void | http_sessions_destroy (http_sessions_t hs) |
void | http_session_destroy (struct http_session *s) |
static void | session_timeout (IOCHAN i, int event) |
struct http_session * | http_session_create (struct conf_service *service, http_sessions_t http_sessions, unsigned int sesid) |
static const char * | get_msg (enum pazpar2_error_code code) |
static void | error2 (struct http_response *rs, enum pazpar2_error_code code, const char *addinfo, const char *addinfo2) |
static void | error (struct http_response *rs, enum pazpar2_error_code code, const char *addinfo) |
static void | response_open_command (struct http_channel *c, const char *command) |
static void | response_open_ok (struct http_channel *c, const char *command) |
static void | response_close (struct http_channel *c, const char *command) |
unsigned int | make_sessionid (void) |
static struct http_session * | locate_session (struct http_channel *c) |
static void | release_session (struct http_channel *c, struct http_session *session) |
static int | process_settings (struct session *se, struct http_request *rq, struct http_response *rs) |
static void | cmd_exit (struct http_channel *c) |
static void | cmd_init (struct http_channel *c) |
static void | apply_local_setting (void *client_data, struct setting *set) |
static void | cmd_settings (struct http_channel *c) |
static void | termlist_response (struct http_channel *c, struct http_session *s, const char *cmd_status) |
static void | termlist_result_ready (void *data) |
static void | cmd_termlist (struct http_channel *c) |
size_t | session_get_memory_status (struct session *session) |
static void | session_status (struct http_channel *c, struct http_session *s) |
static void | cmd_service (struct http_channel *c) |
static void | cmd_session_status (struct http_channel *c) |
static void | bytarget_response (struct http_channel *c, struct http_session *s, const char *cmd_status) |
static void | bytarget_result_ready (void *data) |
static void | cmd_bytarget (struct http_channel *c) |
static void | write_metadata (WRBUF w, struct conf_service *service, struct record_metadata **ml, unsigned flags, int indent) |
static void | write_subrecord (struct record *r, WRBUF w, struct conf_service *service, unsigned flags, int indent) |
static void | show_raw_record_error (void *data, const char *addinfo) |
static void | show_raw_record_ok (void *data, const char *buf, size_t sz) |
static void | show_raw_record_ok_binary (void *data, const char *buf, size_t sz) |
void | show_raw_reset (void *data, struct http_channel *c, void *data2) |
static void | cmd_record_ready (void *data) |
static void | show_record (struct http_channel *c, struct http_session *s) |
static void | cmd_record (struct http_channel *c) |
static void | show_records (struct http_channel *c, struct http_session *s, int active) |
static void | cmd_show (struct http_channel *c) |
static void | cmd_ping (struct http_channel *c) |
static void | cmd_search (struct http_channel *c) |
static void | cmd_stat (struct http_channel *c) |
static void | cmd_stop (struct http_channel *c) |
static void | cmd_info (struct http_channel *c) |
void | http_command (struct http_channel *c) |
Variables | |
static YAZ_MUTEX | g_http_session_mutex = 0 |
static int | g_http_sessions = 0 |
struct { | |
char * name | |
void(* fun )(struct http_channel *c) | |
} | commands [] |
#define HTTP_COMMAND_RESPONSE_PREFIX "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" |
Definition at line 48 of file http_command.c.
#define PAZPAR2_PROTOCOL_VERSION "1" |
Definition at line 46 of file http_command.c.
|
static |
Definition at line 489 of file http_command.c.
References setting::name, session_apply_setting(), setting::target, and setting::value.
Referenced by cmd_settings().
|
static |
Definition at line 686 of file http_command.c.
References hitsbytarget::addinfo, hitsbytarget::approximation, hitsbytarget::diagnostic, hitsbytarget::filtered, get_hitsbytarget(), get_version(), hitsbytarget::hits, http_argbyname(), hitsbytarget::id, hitsbytarget::message, name, hitsbytarget::name, http_channel::nmem, http_session::psession, hitsbytarget::query_data, hitsbytarget::query_type, hitsbytarget::records, http_channel::request, response_close(), response_open_command(), response_open_ok(), session_log(), hitsbytarget::settings_xml, hitsbytarget::state, hitsbytarget::suggestions_xml, and http_channel::wrbuf.
Referenced by bytarget_result_ready(), and cmd_bytarget().
|
static |
Definition at line 774 of file http_command.c.
References bytarget_response(), http_channel::http_sessions, locate_session(), http_sessions::log_level, http_session::psession, release_session(), and session_log().
Referenced by cmd_bytarget().
|
static |
Definition at line 792 of file http_command.c.
References bytarget_response(), bytarget_result_ready(), error(), http_argbyname(), http_channel::http_sessions, locate_session(), http_sessions::log_level, PAZPAR2_ALREADY_BLOCKED, http_session::psession, release_session(), http_channel::request, http_channel::response, session_active_clients(), session_log(), session_set_watch(), and SESSION_WATCH_BYTARGET.
|
static |
Definition at line 405 of file http_command.c.
References parameters::debug_mode, global_parameters, http_close_server(), response_close(), response_open_ok(), and http_channel::server.
|
static |
Definition at line 1428 of file http_command.c.
References clients_get_count(), info_services(), PAZPAR2_VERSION_SHA1, response_close(), response_open_command(), http_channel::server, sessions_get_count(), VERSION, and http_channel::wrbuf.
|
static |
Definition at line 415 of file http_command.c.
References http_request::content_buf, http_request::content_len, error(), http_request::headers, http_argbyname(), http_lookup_header(), http_session_create(), http_channel::http_sessions, locate_service(), make_sessionid(), PAZPAR2_MALFORMED_SETTING, PAZPAR2_NO_SERVICE, PAZPAR2_PROTOCOL_VERSION, process_settings(), http_session::psession, http_channel::request, http_channel::response, response_close(), response_open_ok(), http_channel::server, conf_server::server_id, session::service, service_create(), session_init_databases(), session_log(), conf_service::session_timeout, and http_channel::wrbuf.
|
static |
Definition at line 1313 of file http_command.c.
References locate_session(), release_session(), response_close(), and response_open_ok().
|
static |
Definition at line 1095 of file http_command.c.
References locate_session(), release_session(), and show_record().
|
static |
Definition at line 1082 of file http_command.c.
References http_channel::http_sessions, locate_session(), http_sessions::log_level, http_session::psession, release_session(), session_log(), and show_record().
Referenced by show_record().
|
static |
Definition at line 1323 of file http_command.c.
References conf_service::default_sort, error(), error2(), http_argbyname(), locate_session(), http_channel::nmem, PAZPAR2_MALFORMED_PARAMETER_ENCODING, PAZPAR2_MALFORMED_PARAMETER_VALUE, PAZPAR2_MISSING_PARAMETER, http_session::psession, reclist_parse_sortparms(), release_session(), http_channel::request, http_channel::response, response_close(), response_open_ok(), session::service, and session_search().
|
static |
Definition at line 661 of file http_command.c.
References locate_session(), http_session::psession, release_session(), response_close(), response_open_command(), session::service, http_channel::wrbuf, and conf_service::xml_node.
|
static |
Definition at line 674 of file http_command.c.
References locate_session(), release_session(), response_close(), response_open_ok(), and session_status().
|
static |
Definition at line 497 of file http_command.c.
References apply_local_setting(), http_request::content_buf, http_request::content_len, error(), http_request::headers, http_lookup_header(), locate_session(), PAZPAR2_MALFORMED_SETTING, process_settings(), http_session::psession, release_session(), http_channel::request, http_channel::response, response_close(), response_open_ok(), session_log(), and settings_read_node_x().
|
static |
Definition at line 1216 of file http_command.c.
References conf_service::default_sort, error(), http_argbyname(), http_channel::http_sessions, locate_session(), http_sessions::log_level, http_channel::nmem, PAZPAR2_ALREADY_BLOCKED, PAZPAR2_MALFORMED_PARAMETER_VALUE, http_session::psession, session::reclist, reclist_get_num_records(), reclist_parse_sortparms(), release_session(), http_channel::request, http_channel::response, session::service, session_active_clients(), session_is_preferred_clients_ready(), session_log(), session_set_watch(), session_sort(), SESSION_WATCH_SHOW, SESSION_WATCH_SHOW_PREF, show_records(), and show_records_ready().
|
static |
Definition at line 1382 of file http_command.c.
References locate_session(), statistics::num_clients, statistics::num_connecting, statistics::num_error, statistics::num_failed, statistics::num_hits, statistics::num_idle, statistics::num_no_connection, statistics::num_records, statistics::num_working, http_session::psession, release_session(), response_close(), response_open_command(), session_active_clients(), statistics(), and http_channel::wrbuf.
|
static |
Definition at line 1417 of file http_command.c.
References locate_session(), http_session::psession, release_session(), response_close(), response_open_ok(), and session_stop().
|
static |
Definition at line 590 of file http_command.c.
References error(), http_argbyname(), http_channel::http_sessions, locate_session(), http_sessions::log_level, PAZPAR2_ALREADY_BLOCKED, http_session::psession, release_session(), http_channel::request, http_channel::response, session_active_clients(), session_log(), session_set_watch(), SESSION_WATCH_TERMLIST, termlist_response(), and termlist_result_ready().
|
static |
Definition at line 273 of file http_command.c.
References error2().
Referenced by client_record_response(), client_search_response(), cmd_bytarget(), cmd_init(), cmd_search(), cmd_settings(), cmd_show(), cmd_termlist(), connection_connect(), http_command(), http_init(), locate_session(), non_block_events(), process_settings(), show_raw_record_error(), show_record(), and show_records().
|
static |
Definition at line 241 of file http_command.c.
References http_response::channel, http_response::code, get_msg(), HTTP_COMMAND_RESPONSE_PREFIX, http_send_response(), http_response::msg, http_channel::nmem, and http_response::payload.
Referenced by cmd_search(), and error().
|
static |
Definition at line 208 of file http_command.c.
References PAZPAR2_ALREADY_BLOCKED, PAZPAR2_CONFIG_TARGET, PAZPAR2_HITCOUNTS_FAILED, PAZPAR2_LAST_ERROR, PAZPAR2_MALFORMED_PARAMETER_ENCODING, PAZPAR2_MALFORMED_PARAMETER_VALUE, PAZPAR2_MALFORMED_SETTING, PAZPAR2_MISSING_PARAMETER, PAZPAR2_NO_SERVICE, PAZPAR2_NO_SESSION, PAZPAR2_NO_TARGETS, PAZPAR2_NOT_IMPLEMENTED, PAZPAR2_RECORD_FAIL, and PAZPAR2_RECORD_MISSING.
Referenced by error2().
int get_version | ( | struct http_request * | rq | ) |
Definition at line 73 of file http_command.c.
References http_argbyname().
Referenced by bytarget_response(), show_records(), and termlist_response().
void http_command | ( | struct http_channel * | c | ) |
Definition at line 1497 of file http_command.c.
References commands, error(), http_addheader(), http_argbyname(), http_create_response(), name, PAZPAR2_MALFORMED_PARAMETER_VALUE, PAZPAR2_MISSING_PARAMETER, http_channel::request, and http_channel::response.
Referenced by http_io().
struct http_session* http_session_create | ( | struct conf_service * | service, |
http_sessions_t | http_sessions, | ||
unsigned int | sesid | ||
) |
Definition at line 134 of file http_command.c.
References http_session::activity_counter, http_session::destroy_counter, http_session_use(), http_session::http_sessions, iochan_add(), iochan_create(), conf_server::iochan_man, iochan_setdata, iochan_settimeout, http_sessions::log_level, http_sessions::mutex, http_session::next, http_session::nmem, http_session::psession, conf_service::server, session_create(), http_session::session_id, http_sessions::session_list, session_log(), session_timeout(), conf_service::session_timeout, http_session::timeout_iochan, and http_session::timestamp.
Referenced by cmd_init().
void http_session_destroy | ( | struct http_session * | s | ) |
Definition at line 169 of file http_command.c.
References http_session::activity_counter, http_session::destroy_counter, http_session_use(), http_session::http_sessions, iochan_destroy(), http_sessions::log_level, http_sessions::mutex, http_session::next, http_session::nmem, http_session::psession, session_destroy(), http_sessions::session_list, session_log(), and http_session::timeout_iochan.
Referenced by session_timeout().
int http_session_use | ( | int | delta | ) |
Definition at line 83 of file http_command.c.
References g_http_session_mutex, and g_http_sessions.
Referenced by http_session_create(), and http_session_destroy().
http_sessions_t http_sessions_create | ( | void | ) |
Definition at line 98 of file http_command.c.
References http_sessions::log_level, http_sessions::mutex, pazpar2_mutex_create(), and http_sessions::session_list.
Referenced by http_mutex_init().
void http_sessions_destroy | ( | http_sessions_t | hs | ) |
Definition at line 108 of file http_command.c.
References iochan_destroy(), http_sessions::mutex, http_session::next, http_session::nmem, http_session::psession, session_destroy(), http_sessions::session_list, and http_session::timeout_iochan.
Referenced by http_server_destroy().
|
static |
Definition at line 333 of file http_command.c.
References http_session::activity_counter, error(), http_argbyname(), http_channel::http_sessions, iochan_activity, http_sessions::mutex, http_session::next, PAZPAR2_MISSING_PARAMETER, PAZPAR2_NO_SESSION, http_channel::request, http_channel::response, http_session::session_id, http_sessions::session_list, and http_session::timeout_iochan.
Referenced by bytarget_result_ready(), cmd_bytarget(), cmd_ping(), cmd_record(), cmd_record_ready(), cmd_search(), cmd_service(), cmd_session_status(), cmd_settings(), cmd_show(), cmd_stat(), cmd_stop(), cmd_termlist(), show_records_ready(), and termlist_result_ready().
unsigned int make_sessionid | ( | void | ) |
Definition at line 304 of file http_command.c.
References global_parameters, and parameters::predictable_sessions.
Referenced by cmd_init().
|
static |
Definition at line 375 of file http_command.c.
References http_request::arguments, error(), http_argument::name, http_argument::next, PAZPAR2_MALFORMED_SETTING, session_apply_setting(), and http_argument::value.
Referenced by cmd_init(), and cmd_settings().
|
static |
Definition at line 363 of file http_command.c.
References http_channel::http_sessions, and http_sessions::mutex.
Referenced by bytarget_result_ready(), cmd_bytarget(), cmd_ping(), cmd_record(), cmd_record_ready(), cmd_search(), cmd_service(), cmd_session_status(), cmd_settings(), cmd_show(), cmd_stat(), cmd_stop(), cmd_termlist(), show_records_ready(), and termlist_result_ready().
|
static |
Definition at line 294 of file http_command.c.
References http_send_response(), http_channel::nmem, http_response::payload, http_channel::response, and http_channel::wrbuf.
Referenced by bytarget_response(), cmd_exit(), cmd_info(), cmd_init(), cmd_ping(), cmd_search(), cmd_service(), cmd_session_status(), cmd_settings(), cmd_stat(), cmd_stop(), show_record(), show_records(), and termlist_response().
|
static |
Definition at line 280 of file http_command.c.
References HTTP_COMMAND_RESPONSE_PREFIX, and http_channel::wrbuf.
Referenced by bytarget_response(), cmd_info(), cmd_service(), cmd_stat(), response_open_ok(), show_record(), and termlist_response().
|
static |
Definition at line 288 of file http_command.c.
References response_open_command(), and http_channel::wrbuf.
Referenced by bytarget_response(), cmd_exit(), cmd_init(), cmd_ping(), cmd_search(), cmd_session_status(), cmd_settings(), cmd_stop(), and show_records().
size_t session_get_memory_status | ( | struct session * | session | ) |
Definition at line 1082 of file session.c.
References session::nmem, session_enter(), and session_leave().
Referenced by session_status().
|
static |
Definition at line 650 of file http_command.c.
References http_session::activity_counter, http_session::nmem, http_session::psession, session_get_memory_status(), and http_channel::wrbuf.
Referenced by cmd_session_status().
|
static |
Definition at line 128 of file http_command.c.
References http_session_destroy(), and iochan_getdata.
Referenced by client_prep_connection(), connection_create(), and http_session_create().
|
static |
Definition at line 920 of file http_command.c.
References error(), http_channel_observer_chan(), http_remove_observer(), PAZPAR2_RECORD_FAIL, and http_channel::response.
Referenced by show_record().
|
static |
Definition at line 931 of file http_command.c.
References http_channel_observer_chan(), http_remove_observer(), http_send_response(), http_channel::nmem, http_response::payload, http_channel::response, and http_channel::wrbuf.
Referenced by show_record().
|
static |
Definition at line 945 of file http_command.c.
References http_response::content_type, http_channel_observer_chan(), http_remove_observer(), http_send_response(), http_channel::nmem, http_response::payload, http_channel::response, and http_channel::wrbuf.
Referenced by show_record().
void show_raw_reset | ( | void * | data, |
struct http_channel * | c, | ||
void * | data2 | ||
) |
Definition at line 961 of file http_command.c.
Referenced by show_record().
|
static |
Definition at line 969 of file http_command.c.
References record::checksum, record::client, client_show_raw_begin(), cmd_record_ready(), error(), http_add_observer(), http_argbyname(), http_remove_observer(), record_cluster::metadata, record::next, PAZPAR2_MISSING_PARAMETER, PAZPAR2_NO_SESSION, PAZPAR2_RECORD_FAIL, PAZPAR2_RECORD_MISSING, record::position, http_session::psession, record_cluster::recid, record_cluster::records, http_channel::request, http_channel::response, response_close(), response_open_command(), session::service, session_active_clients(), session_set_watch(), SESSION_WATCH_RECORD, show_raw_record_error(), show_raw_record_ok(), show_raw_record_ok_binary(), show_raw_reset(), show_single_start(), show_single_stop(), http_channel::wrbuf, write_metadata(), and write_subrecord().
Referenced by cmd_record(), and cmd_record_ready().
|
static |
Definition at line 1106 of file http_command.c.
References conf_service::default_sort, error(), get_version(), http_argbyname(), record_cluster::metadata, record::next, http_channel::nmem, PAZPAR2_MALFORMED_PARAMETER_VALUE, http_session::psession, conf_service::rank_debug, record_cluster::recid, reclist_parse_sortparms(), record_cluster::relevance_explain1, record_cluster::relevance_explain2, record_cluster::relevance_score, http_channel::request, http_channel::response, response_close(), response_open_ok(), session::service, session_active_clients(), show_range_start(), show_range_stop(), show_records_ready(), http_channel::wrbuf, write_metadata(), and write_subrecord().
Referenced by cmd_show(), and show_records_ready().
|
static |
Definition at line 1200 of file http_command.c.
References http_channel::http_sessions, locate_session(), http_sessions::log_level, http_session::psession, release_session(), session_log(), and show_records().
Referenced by cmd_show(), show_range_start(), and show_records().
|
static |
Definition at line 546 of file http_command.c.
References get_version(), http_argbyname(), name, perform_termlist(), http_session::psession, http_channel::request, response_close(), response_open_command(), session_active_clients(), and http_channel::wrbuf.
Referenced by cmd_termlist(), and termlist_result_ready().
|
static |
Definition at line 572 of file http_command.c.
References http_argbyname(), http_channel::http_sessions, locate_session(), http_sessions::log_level, http_session::psession, release_session(), http_channel::request, session_log(), and termlist_response().
Referenced by cmd_termlist().
|
static |
Definition at line 845 of file http_command.c.
References record_metadata::attributes, conf_metadata::brief, record_metadata::data, data_types::disp, data_types::fnumber, data_types::max, conf_service::metadata, Metadata_type_float, Metadata_type_generic, Metadata_type_year, data_types::min, conf_metadata::name, record_metadata_attr::name, record_metadata_attr::next, record_metadata::next, conf_service::num_metadata, data_types::number, data_types::snippet, data_types::text, conf_metadata::type, and record_metadata_attr::value.
Referenced by show_record(), show_records(), and write_subrecord().
|
static |
Definition at line 897 of file http_command.c.
References record::checksum, record::client, client_get_database(), client_get_id(), record::metadata, name, PZ_NAME, session_setting_oneval(), and write_metadata().
Referenced by show_record(), and show_records().
struct { ... } commands[] |
Referenced by http_command().
void(* fun) (struct http_channel *c) | ( | struct http_channel * | c | ) |
Definition at line 1478 of file http_command.c.
Referenced by read_settings(), read_settings_file(), session_alert_watch(), and session_set_watch().
|
static |
Definition at line 68 of file http_command.c.
Referenced by http_session_use().
|
static |
Definition at line 69 of file http_command.c.
Referenced by http_session_use().
char* name |
Definition at line 1477 of file http_command.c.
Referenced by apply_limit(), bytarget_response(), check_limit_local(), client_get_facet_limit_local(), client_has_facet(), conf_service_add_metadata(), conf_service_add_sortkey(), conf_service_metadata_field_id(), conf_service_sortkey_field_id(), get_mergekey_from_doc(), hitsbytarget_nb(), http_addheader(), http_argbyname(), http_command(), http_header_append(), http_headerbyname(), http_lookup_header(), initialize_soft_settings(), iochan_create(), pazpar2_mutex_create(), perform_termlist(), record_create(), relevance_countwords(), service_create_static(), session_apply_setting(), session_check_cluster_limit(), settings_create_offset(), settings_index_lookup(), settings_lookup_offset(), settings_read_node_x(), targets_termlist_nb(), termlist_response(), and write_subrecord().