From bc04e18bcab36d307a8e4c820c7d309e71cf6d69 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 13 Jun 2007 13:04:34 +0000 Subject: [PATCH] Fixed bug #1187: command=show crashes if used before a search is performed. Also changed log of session destroy to actually log what session gets destroyed. --- src/http_command.c | 5 ++-- src/logic.c | 64 ++++++++++++++++++++++++++++++---------------------- 2 files changed, 40 insertions(+), 29 deletions(-) diff --git a/src/http_command.c b/src/http_command.c index eaf4785..3128fec 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -1,4 +1,4 @@ -/* $Id: http_command.c,v 1.51 2007-06-13 08:04:03 adam Exp $ +/* $Id: http_command.c,v 1.52 2007-06-13 13:04:34 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -20,7 +20,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA */ /* - * $Id: http_command.c,v 1.51 2007-06-13 08:04:03 adam Exp $ + * $Id: http_command.c,v 1.52 2007-06-13 13:04:34 adam Exp $ */ #include @@ -97,6 +97,7 @@ void http_session_destroy(struct http_session *s) *p = (*p)->next; break; } + yaz_log(YLOG_LOG, "Destroying session %u", s->session_id); iochan_destroy(s->timeout_iochan); destroy_session(s->psession); nmem_destroy(s->nmem); diff --git a/src/logic.c b/src/logic.c index e61d811..b02deac 100644 --- a/src/logic.c +++ b/src/logic.c @@ -1,4 +1,4 @@ -/* $Id: logic.c,v 1.41 2007-06-13 08:04:03 adam Exp $ +/* $Id: logic.c,v 1.42 2007-06-13 13:04:34 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -651,7 +651,6 @@ void destroy_session(struct session *s) { struct session_database *sdb; - yaz_log(YLOG_LOG, "Destroying session"); while (s->clients) client_destroy(s->clients); for (sdb = s->databases; sdb; sdb = sdb->next) @@ -667,6 +666,7 @@ struct session *new_session(NMEM nmem) yaz_log(YLOG_DEBUG, "New Pazpar2 session"); + session->relevance = 0; session->total_hits = 0; session->total_records = 0; session->num_termlists = 0; @@ -756,34 +756,44 @@ struct record_cluster **show(struct session *s, struct reclist_sortparms *sp, yaz_timing_t t = yaz_timing_create(); #endif - for (spp = sp; spp; spp = spp->next) - if (spp->type == Metadata_sortkey_relevance) - { - relevance_prepare_read(s->relevance, s->reclist); - break; - } - reclist_sort(s->reclist, sp); - - *total = s->reclist->num_records; - *sumhits = s->total_hits; - - for (i = 0; i < start; i++) - if (!reclist_read_record(s->reclist)) - { - *num = 0; - recs = 0; - break; - } - - for (i = 0; i < *num; i++) + if (!s->relevance) + { + *num = 0; + *total = 0; + *sumhits = 0; + recs = 0; + } + else { - struct record_cluster *r = reclist_read_record(s->reclist); - if (!r) + for (spp = sp; spp; spp = spp->next) + if (spp->type == Metadata_sortkey_relevance) + { + relevance_prepare_read(s->relevance, s->reclist); + break; + } + reclist_sort(s->reclist, sp); + + *total = s->reclist->num_records; + *sumhits = s->total_hits; + + for (i = 0; i < start; i++) + if (!reclist_read_record(s->reclist)) + { + *num = 0; + recs = 0; + break; + } + + for (i = 0; i < *num; i++) { - *num = i; - break; + struct record_cluster *r = reclist_read_record(s->reclist); + if (!r) + { + *num = i; + break; + } + recs[i] = r; } - recs[i] = r; } #if USE_TIMING yaz_timing_stop(t); -- 1.7.10.4