X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Freclists.c;h=8ef9ba4cc34e4337300f433bca02f8399594acdb;hb=d08893d173565ccde81b9f7cbf487a67cee5532a;hp=366ccae14642534e697b27c9b6cdc98d70f99a59;hpb=1003956798f3820c5b47ac6d20b8375ee0786788;p=pazpar2-moved-to-github.git diff --git a/src/reclists.c b/src/reclists.c index 366ccae..8ef9ba4 100644 --- a/src/reclists.c +++ b/src/reclists.c @@ -1,5 +1,5 @@ /* This file is part of Pazpar2. - Copyright (C) 2006-2012 Index Data + Copyright (C) 2006-2013 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 @@ -209,31 +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)) - { - *pp = p; - pp = &p->sorted_next; - num++; - } - else + struct reclist_bucket *p; + for (p = l->hashtable[i]; p; p = p->hash_next) { - yaz_log(YLOG_LOG, "session_check_cluster returned false"); + 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); } @@ -366,21 +366,20 @@ struct record_cluster *reclist_insert(struct reclist *l, // We found a matching record. Merge them if (!strcmp(merge_key, (*p)->record->merge_key)) { - struct record_cluster *existing = (*p)->record; - struct record *re = existing->records; + struct record **re; - for (; re; re = re->next) + cluster = (*p)->record; + for (re = &cluster->records; *re; re = &(*re)->next) { - if (re->client == record->client && - record_compare(record, re, service)) + if ((*re)->client == record->client && + record_compare(record, *re, service)) { yaz_mutex_leave(l->mutex); return 0; } } - record->next = existing->records; - existing->records = record; - cluster = existing; + *re = record; + record->next = 0; break; } }