+Timeout values may be given per-service. That's element 'timeout'
+which takes three attribute values (a subset may be given): 'session',
+'z3950_connect', 'z3950_session'. Option -T is no longer supported
+- used to specify session timeout.
+
Option -t tests the Pazpar2 configuration and returns exit code
(0=success, non-zero=failure). In previous version of Pazpar2, -t
specified local settings.
<arg choice="opt"><option>-l <replaceable>logfile</replaceable></option></arg>
<arg choice="opt"><option>-p <replaceable>pidfile</replaceable></option></arg>
<arg choice="opt"><option>-t</option></arg>
- <arg choice="opt"><option>-T <replaceable>session_timeout</replaceable></option></arg>
<arg choice="opt"><option>-u <replaceable>uid</replaceable></option></arg>
<arg choice="opt"><option>-V</option></arg>
<arg choice="opt"><option>-X</option></arg>
</varlistentry>
<varlistentry>
- <term><option>-T <replaceable>session_timeout</replaceable></option></term>
- <listitem>
- <para>
- Specifies a Pazpar2 HTTP session timeout. This
- overrides the default value of 60 seconds which is to low for some broken browser.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
<term><option>-u <replaceable>uid</replaceable></option></term>
<listitem>
<para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>timeout</term>
+ <listitem>
+ <para>
+ Specifies timeout parameters for this service.
+ The <literal>timeout</literal>
+ element supports the following attributes:
+ <literal>session</literal>, <literal>z3950_connect</literal>,
+ <literal>z3950_session</literal> which specifies
+ 'session timeout', 'Z39.50 connect timeout', 'Z39.50 session timeout'
+ respectively.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist> <!-- Data elements in service directive -->
</listitem>
</varlistentry>
</icu_chain>
</relevance>
<settings src="mysettings"/>
+ <timeout session="60"/>
<service>
</server>
</pazpar2>
void client_set_connection(struct client *cl, struct connection *con);
void client_disconnect(struct client *cl);
-int client_prep_connection(struct client *cl);
+int client_prep_connection(struct client *cl,
+ int connect_timeout, int session_timeout);
void client_start_search(struct client *cl);
void client_set_session(struct client *cl, struct session *se);
int client_is_active(struct client *cl);
Conn_Connecting,
Conn_Open
} state;
+ int connect_timeout;
+ int session_timeout;
struct connection *next; // next for same host or next in free list
};
// Creates a new connection for client, associated with the host of
// client's database
-static struct connection *connection_create(struct client *cl)
+static struct connection *connection_create(struct client *cl,
+ int connect_timeout,
+ int session_timeout)
{
struct connection *new;
struct host *host = client_get_host(cl);
client_set_connection(cl, new);
new->link = 0;
new->state = Conn_Resolving;
+ new->connect_timeout = connect_timeout;
+ new->session_timeout = session_timeout;
if (host->ipport)
connection_connect(new);
return new;
case ZOOM_EVENT_CONNECT:
yaz_log(YLOG_LOG, "Connected to %s", client_get_url(cl));
co->state = Conn_Open;
- iochan_settimeout(iochan, global_parameters.z3950_session_timeout);
+ iochan_settimeout(iochan, co->session_timeout);
break;
case ZOOM_EVENT_RECV_SEARCH:
client_search_response(cl);
con->link = link;
con->iochan = iochan_create(0, connection_handler, 0);
con->state = Conn_Connecting;
- iochan_settimeout(con->iochan, global_parameters.z3950_connect_timeout);
+ iochan_settimeout(con->iochan, con->connect_timeout);
iochan_setdata(con->iochan, con);
iochan_setsocketfun(con->iochan, socketfun);
iochan_setmaskfun(con->iochan, maskfun);
}
// Ensure that client has a connection associated
-int client_prep_connection(struct client *cl)
+int client_prep_connection(struct client *cl,
+ int connect_timeout, int session_timeout)
{
struct connection *co;
struct session *se = client_get_session(cl);
co->client = cl;
/* tells ZOOM to reconnect if necessary. Disabled becuase
the ZOOM_connection_connect flushes the task queue */
+ co->connect_timeout = connect_timeout;
+ co->session_timeout = session_timeout;
ZOOM_connection_connect(co->link, 0, 0);
}
else
{
- co = connection_create(cl);
+ co = connection_create(cl, connect_timeout, session_timeout);
}
}
void connection_destroy(struct connection *co);
void connect_resolver_host(struct host *host);
-int connection_prep_connection(struct connection *co, struct session *se);
const char *connection_get_url(struct connection *co);
void connection_release(struct connection *co);
ZOOM_connection connection_get_link(struct connection *co);
session_list = r;
r->timeout_iochan = iochan_create(-1, session_timeout, 0);
iochan_setdata(r->timeout_iochan, r);
- iochan_settimeout(r->timeout_iochan, global_parameters.session_timeout);
+ iochan_settimeout(r->timeout_iochan, service->session_timeout);
pazpar2_add_channel(r->timeout_iochan);
return r;
{
0, // dump_records
0, // debug_mode
- 60, // session timeout
100,
- 180, // Z39.50 session timeout
- 15 // Connect timeout
};
static void log_xml_doc(xmlDoc *doc)
else
{
no_working++;
- if (client_prep_connection(cl))
+ if (client_prep_connection(cl, se->service->z3950_connect_timeout,
+ se->service->z3950_session_timeout))
client_start_search(cl);
}
}
struct parameters {
int dump_records;
int debug_mode;
- int session_timeout;
int toget;
- int z3950_session_timeout;
- int z3950_connect_timeout;
};
extern struct parameters global_parameters;
char *arg;
const char *pidfile = 0;
const char *uid = 0;
- int session_timeout = 60;
const char *listener_override = 0;
const char *config_fname = 0;
struct conf_config *config = 0;
yaz_log_init_prefix("pazpar2");
yaz_log_xml_errors(0, YLOG_WARN);
- while ((ret = options("dDf:h:l:p:tT:u:VX", argv, argc, &arg)) != -2)
+ while ((ret = options("dDf:h:l:p:tu:VX", argv, argc, &arg)) != -2)
{
switch (ret)
{
case 't':
test_mode = 1;
break;
- case 'T':
- session_timeout = atoi(arg);
- if (session_timeout < 9 || session_timeout > 86400)
- {
- yaz_log(YLOG_FATAL, "Session timeout out of range 10..86400: %d",
- session_timeout);
- return 1;
- }
- global_parameters.session_timeout = session_timeout;
- break;
case 'u':
uid = arg;
break;
" -l file Log to file\n"
" -p pidfile PID file\n"
" -t Test configuration\n"
- " -T session_timeout Session timeout\n"
" -u uid Change user to uid\n"
" -V Show version\n"
" -X Debug mode\n"
service->databases = 0;
service->targetprofiles = 0;
service->config = config;
+ service->session_timeout = 60; /* default session timeout */
+ service->z3950_session_timeout = 180;
+ service->z3950_connect_timeout = 15;
service->relevance_pct = 0;
service->sort_pct = 0;
{
if (n->type != XML_ELEMENT_NODE)
continue;
- if (!strcmp((const char *) n->name, "settings"))
+ if (!strcmp((const char *) n->name, "timeout"))
+ {
+ xmlChar *src = xmlGetProp(n, (xmlChar *) "session");
+ if (src)
+ {
+ service->session_timeout = atoi((const char *) src);
+ xmlFree(src);
+ if (service->session_timeout < 9)
+ {
+ yaz_log(YLOG_FATAL, "session timeout out of range");
+ return 0;
+ }
+ }
+ src = xmlGetProp(n, (xmlChar *) "z3950_connect");
+ if (src)
+ {
+ service->z3950_connect_timeout = atoi((const char *) src);
+ xmlFree(src);
+ if (service->z3950_session_timeout < 9)
+ {
+ yaz_log(YLOG_FATAL, "Z39.50 connect timeout out of range");
+ return 0;
+ }
+ }
+ src = xmlGetProp(n, (xmlChar *) "z3950_session");
+ if (src)
+ {
+ service->z3950_session_timeout = atoi((const char *) src);
+ xmlFree(src);
+ if (service->z3950_session_timeout < 9)
+ {
+ yaz_log(YLOG_FATAL, "Z39.50 session timeout out of range");
+ return 0;
+ }
+ }
+ }
+ else if (!strcmp((const char *) n->name, "settings"))
got_settings++;
else if (!strcmp((const char *) n->name, (const char *) "targetprofiles"))
{
char *id;
char *settings;
NMEM nmem;
-
+ int session_timeout;
+ int z3950_session_timeout;
+ int z3950_connect_timeout;
+
/* duplicated from conf_server */
pp2_charset_t relevance_pct;
pp2_charset_t sort_pct;