X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=isamb%2Fisamb.c;h=9d4d4008588ad1cb8fd2c9af92d5cb9459c2b1d9;hb=28045b27be52a2f8ac41900051612f5640cea165;hp=f69d05624341a4364fa239b6a65b4747d0e5223a;hpb=a4d1fff3d8575f7f3db84630cc408fdd8d051f8f;p=idzebra-moved-to-github.git diff --git a/isamb/isamb.c b/isamb/isamb.c index f69d056..9d4d400 100644 --- a/isamb/isamb.c +++ b/isamb/isamb.c @@ -1,5 +1,5 @@ -/* $Id: isamb.c,v 1.90 2006-12-19 00:25:41 adam Exp $ - Copyright (C) 1995-2006 +/* $Id: isamb.c,v 1.93 2007-04-03 16:54:46 adam Exp $ + Copyright (C) 1995-2007 Index Data ApS This file is part of the Zebra server. @@ -291,17 +291,20 @@ ISAMB isamb_open2(BFiles bfs, const char *name, int writeflag, ISAMC_M *method, if (memcmp(hbuf, "isamb", 5)) { yaz_log(YLOG_WARN, "bad isamb header for file %s", fname); + isamb_close(isamb); return 0; } if (sscanf(hbuf+5, "%d %d %d", &major, &minor, &len) != 3) { yaz_log(YLOG_WARN, "bad isamb header for file %s", fname); + isamb_close(isamb); return 0; } if (major != ISAMB_MAJOR_VERSION) { yaz_log(YLOG_WARN, "bad major version for file %s %d, must be %d", fname, major, ISAMB_MAJOR_VERSION); + isamb_close(isamb); return 0; } for (left = len - sizes[i]; left > 0; left = left - sizes[i]) @@ -312,6 +315,7 @@ ISAMB isamb_open2(BFiles bfs, const char *name, int writeflag, ISAMC_M *method, yaz_log(YLOG_WARN, "truncated isamb header for " "file=%s len=%d pos=%d", fname, len, pos); + isamb_close(isamb); return 0; } } @@ -327,7 +331,11 @@ ISAMB isamb_open2(BFiles bfs, const char *name, int writeflag, ISAMC_M *method, decode_ptr(&src, &isamb->root_ptr); } assert (isamb->file[i].head.block_size >= isamb->file[i].head.block_offset); - isamb->file[i].head_dirty = 0; + /* must rewrite the header if root ptr is in use (bug #1017) */ + if (use_root_ptr && writeflag) + isamb->file[i].head_dirty = 1; + else + isamb->file[i].head_dirty = 0; assert(isamb->file[i].head.block_size == sizes[i]); } #if ISAMB_DEBUG @@ -450,6 +458,7 @@ void isamb_close (ISAMB isamb) yaz_log(YLOG_DEBUG, "isamb_close returned "ZINT_FORMAT" values, " "skipped "ZINT_FORMAT, isamb->skipped_numbers, isamb->returned_numbers); + for (i = 0; ino_cat; i++) { flush_blocks (isamb, i);