X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fhttp_command.c;h=7c23404aac6f1ab81f1d4c2fa48ac3aae583b44e;hb=dfa3f5aa5c191a7e528e09789fce3d82d62c8e51;hp=f11ae21dfc66867be83eff503df1019daf624d42;hpb=98124d717cec040bd63d002a95fded3ab82064fc;p=pazpar2-moved-to-github.git diff --git a/src/http_command.c b/src/http_command.c index f11ae21..7c23404 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -1,5 +1,5 @@ /* This file is part of Pazpar2. - Copyright (C) 2006-2013 Index Data + Copyright (C) Index Data Pazpar2 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -299,7 +299,7 @@ static void error(struct http_response *rs, enum pazpar2_error_code code, const char *addinfo) { - return error2(rs, code, addinfo, 0); + error2(rs, code, addinfo, 0); } static void response_open_command(struct http_channel *c, const char *command) @@ -401,6 +401,7 @@ static int process_settings(struct session *se, struct http_request *rq, struct http_response *rs) { struct http_argument *a; + NMEM nmem = nmem_create(); for (a = rq->arguments; a; a = a->next) if (strchr(a->name, '[')) @@ -411,17 +412,18 @@ static int process_settings(struct session *se, struct http_request *rq, 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; } @@ -507,9 +509,7 @@ static void apply_local_setting(void *client_data, { 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) @@ -788,9 +788,9 @@ static void bytarget_response(struct http_channel *c, struct http_session *s, wrbuf_printf(c->wrbuf, "%d\n", ht[i].records - ht[i].filtered); + wrbuf_printf(c->wrbuf, "%d\n", ht[i].filtered); if (version >= 2) { - wrbuf_printf(c->wrbuf, "%d\n", ht[i].filtered); wrbuf_printf(c->wrbuf, "" ODR_INT_PRINTF "\n", ht[i].approximation); } @@ -925,6 +925,9 @@ static void write_metadata(WRBUF w, struct conf_service *service, if (md->data.number.min != md->data.number.max) wrbuf_printf(w, "-%d", md->data.number.max); break; + case Metadata_type_float: + wrbuf_printf(w, "%f", md->data.fnumber); + break; default: wrbuf_puts(w, "[can't represent]"); break; @@ -1285,7 +1288,7 @@ static void cmd_show(struct http_channel *c) status = session_active_clients(s->psession); - if (block) + if (block && reclist_get_num_records(s->psession->reclist) == 0) { if (!strcmp(block, "preferred") && !session_is_preferred_clients_ready(s->psession) @@ -1454,6 +1457,17 @@ static void cmd_stat(struct http_channel *c) 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]; @@ -1513,6 +1527,7 @@ struct { { "ping", cmd_ping }, { "record", cmd_record }, { "info", cmd_info }, + { "stop", cmd_stop }, {0,0} };