elements specific to Pazpar2 should belong to the namespace
<literal>http://www.indexdata.com/pazpar2/1.0</literal>
(this is assumed in the
- following examples). The root element is named <literal>pazpar2</literal>.
+ following examples). The root element is named "<literal>pazpar2</literal>".
Under the root element are a number of elements which group categories of
information. The categories are described below.
</para>
+ <refsect2 id="config-threads"><title>threads</title>
+ <para>
+ This section is optional and is supported for Pazpar2 version 1.3.1 and
+ later . It is identified by element "<literal>threads</literal>" which
+ may include one attribute "<literal>number</literal>" which specifies
+ the number of worker-threads that the Pazpar2 instance is to use.
+ A value of 0 (zero) disables worker-threads (all work is carried out
+ in main thread).
+ </para>
+ </refsect2>
<refsect2 id="config-server"><title>server</title>
<para>
- This section governs overall behavior of the server. It is identified
+ This section governs overall behavior of a server endpoint. It is identified
by the element "server" which takes an optional attribute, "id", which
identifies this particular Pazpar2 server. Any string value for "id"
may be given.
<?xml version="1.0" encoding="UTF-8"?>
<pazpar2 xmlns="http://www.indexdata.com/pazpar2/1.0">
+ <threads number="10"/>
<server>
<listen port="9004"/>
<service>
IOCHAN channel_list;
sel_thread_t sel_thread;
int sel_fd;
- int use_threads;
+ int no_threads;
};
-iochan_man_t iochan_man_create(int use_threads)
+iochan_man_t iochan_man_create(int no_threads)
{
iochan_man_t man = xmalloc(sizeof(*man));
man->channel_list = 0;
man->sel_thread = 0; /* can't create sel_thread yet because we may fork */
man->sel_fd = -1;
- man->use_threads = use_threads;
+ man->no_threads = no_threads;
return man;
}
void iochan_man_events(iochan_man_t man)
{
- if (man->use_threads && !man->sel_thread)
+ if (man->no_threads > 0 && !man->sel_thread)
{
man->sel_thread = sel_thread_create(
- work_handler, 0 /*work_destroy */, &man->sel_fd, 10);
- yaz_log(YLOG_LOG, "iochan_man_events. sel_thread started");
+ work_handler, 0 /*work_destroy */, &man->sel_fd, man->no_threads);
+ yaz_log(YLOG_LOG, "iochan_man_events. Using %d threads",
+ man->no_threads);
}
event_loop(man, &man->channel_list);
}
} *IOCHAN;
-iochan_man_t iochan_man_create(int use_threads);
+iochan_man_t iochan_man_create(int no_threads);
void iochan_add(iochan_man_t man, IOCHAN chan);
void iochan_man_events(iochan_man_t man);
void iochan_man_destroy(iochan_man_t *mp);
// Master list of connections we're handling events to
static iochan_man_t pazpar2_chan_man = 0; /* thread pr */
-void pazpar2_chan_man_start(void)
+void pazpar2_chan_man_start(int no_threads)
{
- pazpar2_chan_man = iochan_man_create(0 /* use threads */);
+ pazpar2_chan_man = iochan_man_create(no_threads);
}
void pazpar2_add_channel(IOCHAN chan)
"mode");
return 1;
}
- pazpar2_chan_man_start();
ret = config_start_listeners(config, listener_override);
if (ret)
return ret; /* error starting http listener */
{
NMEM nmem; /* for conf_config and servers memory */
struct conf_server *servers;
+ int no_threads;
WRBUF confdir;
};
tmp->next = config->servers;
config->servers = tmp;
}
+ else if (!strcmp((const char *) n->name, "threads"))
+ {
+ xmlChar *number = xmlGetProp(n, (xmlChar *) "number");
+ if (number)
+ {
+ config->no_threads = atoi(number);
+ xmlFree(number);
+ }
+ }
else if (!strcmp((const char *) n->name, "targetprofiles"))
{
yaz_log(YLOG_FATAL, "targetprofiles unsupported here. Must be part of service");
config->nmem = nmem;
config->servers = 0;
+ config->no_threads = 0;
config->confdir = wrbuf_alloc();
if ((p = strrchr(fname,
const char *listener_override)
{
struct conf_server *ser;
+ pazpar2_chan_man_start(conf->no_threads);
for (ser = conf->servers; ser; ser = ser->next)
{
WRBUF w = wrbuf_alloc();
YAZ_CHECK(p);
if (p)
{
- iochan_man_t chan_man = iochan_man_create(1 /* use_threads */);
+ iochan_man_t chan_man = iochan_man_create(10);
IOCHAN chan = iochan_create(thread_fd, iochan_handler,
EVENT_INPUT|EVENT_TIMEOUT);
iochan_settimeout(chan, 1);