From 8cb5fdac44498271111dce8145623bded04cc27f Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 13 Aug 2013 14:35:43 +0200 Subject: [PATCH] Ensure sorted reclists even if now show is performed This is part of PAZ-884 --- src/reclists.c | 22 +++++++++++++--------- src/reclists.h | 2 +- src/session.c | 3 ++- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/reclists.c b/src/reclists.c index 99c033e..0a9bd8c 100644 --- a/src/reclists.c +++ b/src/reclists.c @@ -209,27 +209,31 @@ static int reclist_cmp(const void *p1, const void *p2) return res; } -void reclist_limit(struct reclist *l, struct session *se) +void reclist_limit(struct reclist *l, struct session *se, int lazy) { unsigned i; int num = 0; struct reclist_bucket **pp = &l->sorted_list; reclist_enter(l); - for (i = 0; i < l->hash_size; i++) + + if (!lazy || !*pp) { - struct reclist_bucket *p; - for (p = l->hashtable[i]; p; p = p->hash_next) + for (i = 0; i < l->hash_size; i++) { - if (session_check_cluster_limit(se, p->record)) + struct reclist_bucket *p; + for (p = l->hashtable[i]; p; p = p->hash_next) { - *pp = p; - pp = &p->sorted_next; - num++; + if (session_check_cluster_limit(se, p->record)) + { + *pp = p; + pp = &p->sorted_next; + num++; + } } } + *pp = 0; } - *pp = 0; l->num_records = num; reclist_leave(l); } diff --git a/src/reclists.h b/src/reclists.h index ea87d80..ba495bd 100644 --- a/src/reclists.h +++ b/src/reclists.h @@ -37,7 +37,7 @@ struct reclist_sortparms struct reclist *reclist_create(NMEM); void reclist_destroy(struct reclist *l); -void reclist_limit(struct reclist *l, struct session *session); +void reclist_limit(struct reclist *l, struct session *session, int lazy); struct record_cluster *reclist_insert(struct reclist *tl, struct conf_service *service, struct record *record, diff --git a/src/session.c b/src/session.c index 0aaec33..77d9ee8 100644 --- a/src/session.c +++ b/src/session.c @@ -1240,6 +1240,7 @@ struct record_cluster *show_single_start(struct session *se, const char *id, session_enter(se, "show_single_start"); *prev_r = 0; *next_r = 0; + reclist_limit(se->reclist, se, 1); reclist_enter(se->reclist); while ((r = reclist_read_record(se->reclist))) @@ -1313,7 +1314,7 @@ struct record_cluster **show_range_start(struct session *se, *sumhits = 0; *approx_hits = 0; *total = 0; - reclist_limit(se->reclist, se); + reclist_limit(se->reclist, se, 0); if (se->relevance) { for (spp = sp; spp; spp = spp->next) -- 1.7.10.4