hs->session_list = 0;
hs->mutex = 0;
pazpar2_mutex_create(&hs->mutex, "http_sessions");
- hs->log_level = yaz_log_module_level("HTTP");
+ hs->log_level = yaz_log_module_level("http");
return hs;
}
char tmp_str[50];
sprintf(tmp_str, "session#%u", sesid);
- r->psession = new_session(nmem, service, sesid);
+ r->psession = session_create(nmem, service, sesid);
r->session_id = sesid;
r->timestamp = 0;
r->nmem = nmem;
struct http_response *rs)
{
struct http_argument *a;
+ NMEM nmem = nmem_create();
for (a = rq->arguments; a; a = a->next)
if (strchr(a->name, '['))
char *setting;
// Nmem_strsplit *rules*!!!
- nmem_strsplit(se->session_nmem, "[]", a->name, &res, &num);
+ nmem_strsplit(nmem, "[]", a->name, &res, &num);
if (num != 2)
{
error(rs, PAZPAR2_MALFORMED_SETTING, a->name);
+ nmem_destroy(nmem);
return -1;
}
setting = res[0];
dbname = res[1];
- session_apply_setting(se, dbname, setting,
- nmem_strdup(se->session_nmem, a->value));
+ session_apply_setting(se, dbname, setting, a->value);
}
+ nmem_destroy(nmem);
return 0;
}
{
struct session *se = (struct session *) client_data;
- session_apply_setting(se, nmem_strdup(se->session_nmem, set->target),
- nmem_strdup(se->session_nmem, set->name),
- nmem_strdup(se->session_nmem, set->value));
+ session_apply_setting(se, set->target, set->name, set->value);
}
static void cmd_settings(struct http_channel *c)
release_session(c, s);
}
-#ifdef HAVE_RESULTSETS_COUNT
-int resultsets_count(void);
-#else
-#define resultsets_count() 0
-#endif
-
static void cmd_server_status(struct http_channel *c)
{
int sessions = sessions_count();
int clients = clients_count();
- int resultsets = resultsets_count();
response_open_ok(c, "server-status");
- wrbuf_printf(c->wrbuf, "\n <sessions>%u</sessions>\n", sessions);
- wrbuf_printf(c->wrbuf, " <clients>%u</clients>\n", clients);
- /* Only works if yaz has been compiled with enabling of this */
- wrbuf_printf(c->wrbuf, " <resultsets>%u</resultsets>\n",resultsets);
+
+ wrbuf_printf(c->wrbuf, "\n <sessions>%d</sessions>\n", sessions);
+ wrbuf_printf(c->wrbuf, " <clients>%d</clients>\n", clients);
print_meminfo(c->wrbuf);
-/* TODO add all sessions status */
-/* http_sessions_t http_sessions = c->http_sessions; */
-/* struct http_session *p; */
-/*
- yaz_mutex_enter(http_sessions->mutex);
- for (p = http_sessions->session_list; p; p = p->next)
- {
- p->activity_counter++;
- wrbuf_puts(c->wrbuf, "<session-status>\n");
- wrbuf_printf(c->wrbuf, "<id>%s</id>\n", p->session_id);
- yaz_mutex_leave(http_sessions->mutex);
- session_status(c, p);
- wrbuf_puts(c->wrbuf, "</session-status>\n");
- yaz_mutex_enter(http_sessions->mutex);
- p->activity_counter--;
- }
- yaz_mutex_leave(http_sessions->mutex);
-*/
response_close(c, "server-status");
xmalloc_trav(0);
}
wrbuf_printf(c->wrbuf, "<records>%d</records>\n",
ht[i].records - ht[i].filtered);
+ wrbuf_printf(c->wrbuf, "<filtered>%d</filtered>\n", ht[i].filtered);
if (version >= 2)
{
- wrbuf_printf(c->wrbuf, "<filtered>%d</filtered>\n", ht[i].filtered);
wrbuf_printf(c->wrbuf, "<approximation>" ODR_INT_PRINTF
"</approximation>\n", ht[i].approximation);
}
wrbuf_puts(c->wrbuf, ht[i].suggestions_xml);
wrbuf_puts(c->wrbuf, "</suggestions>");
}
+ if (ht[i].query_data)
+ {
+ wrbuf_puts(c->wrbuf, "<query_type>");
+ wrbuf_xmlputs(c->wrbuf, ht[i].query_type);
+ wrbuf_puts(c->wrbuf, "</query_type>\n");
+ wrbuf_puts(c->wrbuf, "<query_data>");
+ wrbuf_xmlputs(c->wrbuf, ht[i].query_data);
+ wrbuf_puts(c->wrbuf, "</query_data>\n");
+ }
wrbuf_puts(c->wrbuf, "</target>");
}
response_close(c, "bytarget");
release_session(c, s);
}
+static void cmd_stop(struct http_channel *c)
+{
+ struct http_session *s = locate_session(c);
+ if (!s)
+ return;
+ response_open_ok(c, "stop");
+ session_stop(s->psession);
+ response_close(c, "stop");
+ release_session(c, s);
+}
+
static void cmd_info(struct http_channel *c)
{
char yaz_version_str[20];
{ "ping", cmd_ping },
{ "record", cmd_record },
{ "info", cmd_info },
+ { "stop", cmd_stop },
{0,0}
};