From: Adam Dickmeiss Date: Wed, 10 Sep 2008 12:50:45 +0000 (+0200) Subject: Refactor and rewind fix X-Git-Tag: v2.0.34~26 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;ds=sidebyside;h=2e05c3b9f83d9e7e430dba0bfd31d768234f928e;p=idzebra-moved-to-github.git Refactor and rewind fix Refactored the sort indexing rewind code. The zebra_sort_read could return EOF where it shouldn't. --- diff --git a/index/sortidx.c b/index/sortidx.c index a5d5c7b..5490139 100644 --- a/index/sortidx.c +++ b/index/sortidx.c @@ -315,25 +315,26 @@ int zebra_sort_type(zebra_sort_index_t si, int id) return 0; } +static void zebra_sortf_rewind(struct sortFile *sf) +{ + if (sf->isam_pp) + isamb_pp_close(sf->isam_pp); + sf->isam_pp = 0; + sf->no_inserted = 0; + sf->no_deleted = 0; +} + void zebra_sort_sysno(zebra_sort_index_t si, zint sysno) { - struct sortFile *sf = si->current_file; zint new_sysno = rec_sysno_to_int(sysno); + struct sortFile *sf; for (sf = si->files; sf; sf = sf->next) { if (sf->no_inserted || sf->no_deleted) - { - isamb_pp_close(sf->isam_pp); - sf->isam_pp = 0; - } - else if (sf->isam_pp && new_sysno < si->sysno && sf->isam_pp) - { - isamb_pp_close(sf->isam_pp); - sf->isam_pp = 0; - } - sf->no_inserted = 0; - sf->no_deleted = 0; + zebra_sortf_rewind(sf); + else if (sf->isam_pp && new_sysno <= si->sysno) + zebra_sortf_rewind(sf); } si->sysno = new_sysno; }