From: Dennis Schafroth Date: Mon, 8 Oct 2012 13:23:29 +0000 (+0200) Subject: refactor the search/show to command to use common code path X-Git-Tag: v1.6.22~21 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=05043348d67c1af41483e140829811ed9f6aeb5c;p=pazpar2-moved-to-github.git refactor the search/show to command to use common code path --- diff --git a/src/session.c b/src/session.c index 4900bd2..fa4b4a6 100644 --- a/src/session.c +++ b/src/session.c @@ -56,7 +56,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include -#include #define USE_TIMING 0 #if USE_TIMING @@ -677,10 +676,12 @@ void session_sort(struct session *se, struct reclist_sortparms *sp) for (l = se->clients_active; l; l = l->next) { struct client *cl = l->client; - clients_research += client_test_sort_order(cl, sp); + // Assume no re-search is required. + client_parse_init(cl, 1); + clients_research += client_parse_sort(cl, sp); } if (clients_research) { - yaz_log(YLOG_DEBUG, "Reset results due to %d clients researching"); + yaz_log(YLOG_DEBUG, "Reset results due to %d clients researching", clients_research); session_clear_set(se, sp); } else { @@ -700,15 +701,13 @@ void session_sort(struct session *se, struct reclist_sortparms *sp) if (client_get_state(cl) == Client_Connecting || client_get_state(cl) == Client_Idle || client_get_state(cl) == Client_Working) { - if (client_test_sort_order(cl, sp)) { - yaz_log(YLOG_DEBUG, "Client %s: Restarting search due to change in sort order", client_get_id(cl)); - client_start_search(cl); - } - else { - yaz_log(YLOG_DEBUG, "Client %s: Reingesting due to change in sort order", client_get_id(cl)); - client_reingest(cl); - } + client_start_search(cl); + } + else { + yaz_log(YLOG_DEBUG, "Client %s: Not re-start/ingest in show. Wrong client state: %d", + client_get_id(cl), client_get_state(cl)); } + } session_leave(se); } @@ -727,7 +726,6 @@ enum pazpar2_error_code session_search(struct session *se, int no_failed_query = 0; int no_failed_limit = 0; struct client_list *l, *l0; - struct timeval tval; facet_limits_t facet_limits; int same_sort_order = 0; @@ -757,10 +755,6 @@ enum pazpar2_error_code session_search(struct session *se, return PAZPAR2_NO_TARGETS; } - yaz_gettimeofday(&tval); - - tval.tv_sec += 5; - facet_limits = facet_limits_create(limit); if (!facet_limits) { @@ -777,12 +771,11 @@ enum pazpar2_error_code session_search(struct session *se, { int parse_ret; struct client *cl = l->client; - + client_parse_init(cl, 1); if (prepare_map(se, client_get_database(cl)) < 0) continue; - parse_ret = client_parse_query(cl, query, facet_limits, startrecs, - maxrecs, se->service->ccl_bibset); + parse_ret = client_parse_query(cl, query, facet_limits, se->service->ccl_bibset); if (parse_ret == -1) no_failed_query++; else if (parse_ret == -2) @@ -791,21 +784,9 @@ enum pazpar2_error_code session_search(struct session *se, no_working++; /* other error, such as bad CCL map */ else { - int r = - client_prep_connection(cl, se->service->z3950_operation_timeout, - se->service->z3950_session_timeout, - se->service->server->iochan_man, - &tval); - if (parse_ret == 1 && r == 2 && same_sort_order) - { - session_log(se, YLOG_LOG, "client %s REUSE result", client_get_id(cl)); - client_reingest(cl); - } - else if (r) - { - session_log(se, YLOG_LOG, "client %s NEW search", client_get_id(cl)); - client_start_search(cl); - } + client_parse_range(cl, startrecs, maxrecs); + client_parse_sort(cl, sp); + client_start_search(cl); no_working++; } }