From 194b8961ce560e233440017a65ec1758b3e6b5ec Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 26 Nov 2014 14:38:36 +0100 Subject: [PATCH] Per target timeout PAZ-981 New setting pz:timeout which overrides z3950_operation timeout in service. --- doc/pazpar2_conf.xml | 23 ++++++++++++++++++++++- etc/settings/testserver.xml | 3 ++- src/client.c | 7 ++++++- src/settings.c | 1 + src/settings.h | 3 ++- 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/doc/pazpar2_conf.xml b/doc/pazpar2_conf.xml index 4e82022..08b5a68 100644 --- a/doc/pazpar2_conf.xml +++ b/doc/pazpar2_conf.xml @@ -740,7 +740,7 @@ - + timeout @@ -761,6 +761,10 @@ z3950_operation (30) < session (60) < z3950_session (180) . The default values are given in parantheses. + + The Z39.50 operation timeout may be set per database. Refer to + . + @@ -1589,6 +1593,23 @@ + + + pz:timeout + + + Specifies timeout for operation (eg search, and fetch) for + a database. This overrides the z3650_operation timeout + that is given for a service. See . + + + + The timeout facility is supported for Pazpar2 version 1.8.4 and later. + + + + + pz:url diff --git a/etc/settings/testserver.xml b/etc/settings/testserver.xml index fdb7767..dfdffa4 100644 --- a/etc/settings/testserver.xml +++ b/etc/settings/testserver.xml @@ -1,9 +1,10 @@ - + + diff --git a/src/client.c b/src/client.c index 60553fd..ad2d2a3 100644 --- a/src/client.c +++ b/src/client.c @@ -921,11 +921,13 @@ int client_start_search(struct client *cl) const char *opt_preferred = session_setting_oneval(sdb, PZ_PREFERRED); const char *extra_args = session_setting_oneval(sdb, PZ_EXTRA_ARGS); const char *opt_present_chunk = session_setting_oneval(sdb, PZ_PRESENT_CHUNK); + const char *opt_timeout = session_setting_oneval(sdb, PZ_TIMEOUT); ZOOM_query query; char maxrecs_str[24], startrecs_str[24], present_chunk_str[24]; struct timeval tval; int present_chunk = 20; // Default chunk size int rc_prep_connection; + int operation_timeout = se->service->z3950_operation_timeout; cl->diagnostic = 0; cl->record_failures = cl->ingest_failures = cl->filtered = 0; @@ -933,12 +935,15 @@ int client_start_search(struct client *cl) yaz_gettimeofday(&tval); tval.tv_sec += 5; + if (opt_timeout && *opt_timeout) + operation_timeout = atoi(opt_timeout); + if (opt_present_chunk && strcmp(opt_present_chunk,"")) { present_chunk = atoi(opt_present_chunk); yaz_log(YLOG_DEBUG, "Present chunk set to %d", present_chunk); } rc_prep_connection = - client_prep_connection(cl, se->service->z3950_operation_timeout, + client_prep_connection(cl, operation_timeout, se->service->z3950_session_timeout, se->service->server->iochan_man, &tval); diff --git a/src/settings.c b/src/settings.c index ece8f04..85af04d 100644 --- a/src/settings.c +++ b/src/settings.c @@ -86,6 +86,7 @@ static char *hard_settings[] = { "pz:native_score", "pz:memcached", "pz:redis", + "pz:timeout", 0 }; diff --git a/src/settings.h b/src/settings.h index de43d28..cd01937 100644 --- a/src/settings.h +++ b/src/settings.h @@ -59,7 +59,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define PZ_NATIVE_SCORE 36 #define PZ_MEMCACHED 37 #define PZ_REDIS 38 -#define PZ_MAX_EOF 39 +#define PZ_TIMEOUT 39 +#define PZ_MAX_EOF 40 struct setting { -- 1.7.10.4