#include <yaz/timing.h>
#endif
+#include "ppmutex.h"
#include "parameters.h"
#include "session.h"
#include "eventl.h"
0 // debug_mode
};
+struct client_list {
+ struct client *client;
+ struct client_list *next;
+};
+
static void log_xml_doc(xmlDoc *doc)
{
FILE *lf = yaz_log_file();
{
struct session *se = (struct session*) context;
struct client *cl = client_create();
+ struct client_list *l;
client_set_database(cl, db);
+
client_set_session(cl, se);
+ l = xmalloc(sizeof(*l));
+ l->client = cl;
+ l->next = se->clients;
+ se->clients = l;
}
static void session_remove_clients(struct session *se)
{
- struct client *cl = se->clients;
- while (cl)
+ struct client_list *l = se->clients;
+ while (l)
{
- struct client *cl_next = client_next_in_session(cl);
- client_remove_from_session(cl);
- client_destroy(cl);
- cl = cl_next;
+ struct client_list *l_next = l->next;
+ client_set_session(l->client, 0);
+ client_destroy(l->client);
+ xfree(l);
+ l = l_next;
}
se->clients = 0;
}
int session_active_clients(struct session *s)
{
- struct client *c;
+ struct client_list *l;
int res = 0;
- for (c = s->clients; c; c = client_next_in_session(c))
- if (client_is_active(c))
+ for (l = s->clients; l; l = l->next)
+ if (client_is_active(l->client))
res++;
return res;
int live_channels = 0;
int no_working = 0;
int no_failed = 0;
- struct client *cl;
+ struct client_list *l;
yaz_log(YLOG_DEBUG, "Search");
reclist_destroy(se->reclist);
se->reclist = 0;
nmem_reset(se->nmem);
- se->relevance = 0;
+ relevance_destroy(&se->relevance);
se->total_records = se->total_hits = se->total_merged = 0;
se->num_termlists = 0;
live_channels = select_targets(se, filter);
}
se->reclist = reclist_create(se->nmem);
- for (cl = se->clients; cl; cl = client_next_in_session(cl))
+ for (l = se->clients; l; l = l->next)
{
+ struct client *cl = l->client;
if (maxrecs)
client_set_maxrecs(cl, atoi(maxrecs));
if (startrecs)
for (sdb = s->databases; sdb; sdb = sdb->next)
session_database_destroy(sdb);
normalize_cache_destroy(s->normalize_cache);
+ relevance_destroy(&s->relevance);
reclist_destroy(s->reclist);
nmem_destroy(s->nmem);
service_destroy(s->service);
wrbuf_destroy(s->wrbuf);
}
-struct session *new_session(NMEM nmem, struct conf_service *service)
+struct session *new_session(NMEM nmem, struct conf_service *service,
+ const char *name)
{
int i;
struct session *session = nmem_malloc(nmem, sizeof(*session));
}
session->normalize_cache = normalize_cache_create();
session->mutex = 0;
- yaz_mutex_create(&session->mutex);
+
+ pazpar2_mutex_create(&session->mutex, name);
return session;
}
struct hitsbytarget *hitsbytarget(struct session *se, int *count, NMEM nmem)
{
struct hitsbytarget *res = 0;
- struct client *cl;
+ struct client_list *l;
size_t sz = 0;
session_enter(se);
- for (cl = se->clients; cl; cl = client_next_in_session(cl))
+ for (l = se->clients; l; l = l->next)
sz++;
res = nmem_malloc(nmem, sizeof(*res) * sz);
*count = 0;
- for (cl = se->clients; cl; cl = client_next_in_session(cl))
+ for (l = se->clients; l; l = l->next)
{
+ struct client *cl = l->client;
WRBUF w = wrbuf_alloc();
const char *name = session_setting_oneval(client_get_database(cl),
PZ_NAME);
void statistics(struct session *se, struct statistics *stat)
{
- struct client *cl;
+ struct client_list *l;
int count = 0;
memset(stat, 0, sizeof(*stat));
- for (cl = se->clients; cl; cl = client_next_in_session(cl))
+ for (l = se->clients; l; l = l->next)
{
+ struct client *cl = l->client;
if (!client_get_connection(cl))
stat->num_no_connection++;
switch (client_get_state(cl))
{
const char *norm_str;
pp2_relevance_token_t prt =
- pp2_relevance_tokenize(
- service->mergekey_pct,
- (const char *) value, 0);
+ pp2_relevance_tokenize(service->mergekey_pct);
+ pp2_relevance_first(prt, (const char *) value, 0);
if (wrbuf_len(norm_wr) > 0)
wrbuf_puts(norm_wr, " ");
wrbuf_puts(norm_wr, name);
{
const char *norm_str;
pp2_relevance_token_t prt =
- pp2_relevance_tokenize(
- service->mergekey_pct,
- (const char *) mergekey, 0);
-
+ pp2_relevance_tokenize(service->mergekey_pct);
+
+ pp2_relevance_first(prt, (const char *) mergekey, 0);
while ((norm_str = pp2_relevance_token_next(prt)))
{
if (*norm_str)
nmem_malloc(se->nmem,
sizeof(union data_types));
- prt = pp2_relevance_tokenize(
- service->sort_pct,
- rec_md->data.text.disp, skip_article);
+ prt = pp2_relevance_tokenize(service->sort_pct);
+
+ pp2_relevance_first(prt, rec_md->data.text.disp,
+ skip_article);
pp2_relevance_token_next(prt);