From a12477a52f995b809b00ac9e7b73a9b98cfbc540 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 9 May 2007 07:07:18 +0000 Subject: [PATCH] Fixed bug #1114: scan within set may use excessive CPU. --- NEWS | 4 ++++ index/rpnscan.c | 8 ++++++-- test/api/t11.c | 52 ++++++++++++++++++++++------------------------------ 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/NEWS b/NEWS index 9f85435..de2344b 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +Fixed bug #1114: scan within set may use excessive CPU. + +Fixed memory leak that occurred in scan. + Fixed memory leak that occurred for each deleted record. Optimize updates of records where content is almost identical to previous diff --git a/index/rpnscan.c b/index/rpnscan.c index 242ab45..7800b11 100644 --- a/index/rpnscan.c +++ b/index/rpnscan.c @@ -1,4 +1,4 @@ -/* $Id: rpnscan.c,v 1.10 2007-05-08 14:49:38 adam Exp $ +/* $Id: rpnscan.c,v 1.11 2007-05-09 07:07:18 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -214,6 +214,7 @@ static ZEBRA_RES rpn_scan_ver2(ZebraHandle zh, ODR stream, NMEM nmem, struct scan2_info_entry *ar = nmem_malloc(nmem, sizeof(*ar) * ord_no); struct rpn_char_map_info rcmi; int i, dif; + int after_pos; int pos = 0; ZebraScanEntry *glist = (ZebraScanEntry *) @@ -318,6 +319,7 @@ static ZEBRA_RES rpn_scan_ver2(ZebraHandle zh, ODR stream, NMEM nmem, ar[i].isam_p = 0; } + after_pos = 1; /* immediate term first.. */ for (pos = *position-1; pos < *num_entries; ) { const char *lo = 0; @@ -329,7 +331,7 @@ static ZEBRA_RES rpn_scan_ver2(ZebraHandle zh, ODR stream, NMEM nmem, { char termz[IT_MAX_WORD+20]; int before = 0; - int after = (pos == *position-1) ? 1 : 2; + int after = after_pos; ar[i].pos_to_save = 1; @@ -339,6 +341,8 @@ static ZEBRA_RES rpn_scan_ver2(ZebraHandle zh, ODR stream, NMEM nmem, ar+i, scan_handle2); } } + after_pos = 2; /* next round we grab following term */ + /* get minimum after scan */ for (i = 0; i < ord_no; i++) { diff --git a/test/api/t11.c b/test/api/t11.c index 38dd43d..5ef5298 100644 --- a/test/api/t11.c +++ b/test/api/t11.c @@ -1,4 +1,4 @@ -/* $Id: t11.c,v 1.10 2007-05-08 14:49:38 adam Exp $ +/* $Id: t11.c,v 1.11 2007-05-09 07:07:18 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -48,125 +48,117 @@ static void tst(int argc, char **argv) ) */ -#if 0 - if (1) + { /* bad string use attrite, bug #647 */ YAZ_CHECK(tl_scan(zh, "@attr 1=bad 0", 1, 1, 1, 1, 0, 0)); } - if (1) + { /* bad numeric use attributes, bug #647 */ YAZ_CHECK(tl_scan(zh, "@attr 1=1234 0", 1, 1, 1, 1, 0, 0)); } - if (1) + { /* scan before. nothing must be returned */ const char *ent[] = { "a", 0 }; YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 1, 1, 1, 1, 0, ent)); } - if (1) + { /* scan after. nothing must be returned */ const char *ent[] = { 0 }; YAZ_CHECK(tl_scan(zh, "@attr 1=4 m", 1, 1, 1, 0, 1, ent)); } - if (1) + { const char *ent[] = { "a", 0 }; YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", 1, 1, 1, 1, 0, ent)); } - if (1) + { const char *ent[] = { "b", "c", 0 }; YAZ_CHECK(tl_scan(zh, "@attr 1=4 aa", 1, 2, 1, 2, 0, ent)); } - if (1) + { const char *ent[] = { "b", "c", 0 }; YAZ_CHECK(tl_scan(zh, "@attr 1=4 aa", 1, 2, 1, 2, 0, ent)); } - if (1) + { const char *ent[] = { "e", "f", 0 }; YAZ_CHECK(tl_scan(zh, "@attr 1=4 e", 1, 3, 1, 2, 1, ent)); } - if (1) + { const char *ent[] = { "c", "d", 0 }; YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -1, 2, -1, 2, 0, ent)); } - if (1) + { const char *ent[] = { "d", 0 }; YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -2, 1, -2, 1, 0, ent)); } - if (1) + { const char *ent[] = { "f", 0 }; YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -4, 1, -4, 1, 0, ent)); } - if (1) + { const char *ent[] = { "f", 0 }; YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -5, 1, -5, 0, 1, ent)); } - if (1) + { const char *ent[] = { "d", "e", "f", 0 }; YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -2, 3, -2, 3, 0, ent)); } - if (1) + { const char *ent[] = { "d", "e", "f", 0 }; YAZ_CHECK(tl_scan(zh, "@attr 1=4 a", -2, 4, -2, 3, 1, ent)); } - if (1) + { const char *ent[] = { "a", "b", "c", "d", "e", "f", 0 }; YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 2, 100, 1, 6, 1, ent)); } - if (1) + { const char *ent[] = { "b", "c", "d", "e", "f", 0 }; YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 0, 100, 0, 5, 1, ent)); } - if (1) + { const char *ent[] = { "a", "b", "c", "d", "e", "f", 0 }; YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 10, 100, 1, 6, 1, ent)); } - if (1) + { const char *ent[] = { "a", "b", "c", "d", "e", "f", 0 }; YAZ_CHECK(tl_scan(zh, "@attr 1=4 0", 22, 10, 1, 0, 1, ent)); } - if (1) + { const char *ent[] = { 0 }; YAZ_CHECK(tl_scan(zh, "@attr 1=4 z", -22, 10, -22, 0, 1, ent)); } -#endif - - if (1) { - const char *ent[] = { "a", "b", "c", "d", "e", "f", 0 }; + const char *ent[] = { "c", "d", 0 }; YAZ_CHECK(tl_query(zh, "@attr 1=4 c", 1)); /* must fail, because x is not a result set */ YAZ_CHECK(tl_scan(zh, "@attr 8=x @attr 1=4 a", 1, 3, 0, 0, 0, 0)); -#if 0 /* bug 1114 */ YAZ_CHECK(tl_scan(zh, "@attr 8=rsetname @attr 1=4 0", - 1, 20, 1, 6, 1, ent)); -#endif + 1, 20, 1, 2, 1, ent)); } - - YAZ_CHECK(tl_close_down(zh, zs)); } -- 1.7.10.4