From: Ken Raeburn Date: Fri, 4 Mar 2005 00:05:08 +0000 (+0000) Subject: profile_clear_relation doesn't work, iterator still sees deleted nodes X-Git-Tag: ms-bug-test-20060525~327 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a316a66d3e73df3cc89089ad01fc8673af6cc31e;p=krb5.git profile_clear_relation doesn't work, iterator still sees deleted nodes The "deleted" flag was being checked when writing out the file, but not when iterating through using the profile handle being used to do the deletions. * prof_tree.c (profile_node_iterator): After checking skip_num counter, also skip over deleted nodes. * prof_test1 (test3): New proc. (top level): Run it. ticket: new target_version: 1.4.1 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17111 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/util/profile/ChangeLog b/src/util/profile/ChangeLog index 62da77179..8208db91c 100644 --- a/src/util/profile/ChangeLog +++ b/src/util/profile/ChangeLog @@ -1,3 +1,10 @@ +2005-03-03 Ken Raeburn + + * prof_tree.c (profile_node_iterator): After checking skip_num + counter, also skip over deleted nodes. + * prof_test1 (test3): New proc. + (top level): Run it. + 2005-02-23 Ken Raeburn * prof_tree.c (profile_node_iterator): Check that the root node diff --git a/src/util/profile/prof_test1 b/src/util/profile/prof_test1 index 2907f7a88..bd4901272 100644 --- a/src/util/profile/prof_test1 +++ b/src/util/profile/prof_test1 @@ -1,3 +1,6 @@ +# To do: Should run all tests and return a useful exit status, not +# punt on the first failure. + set wd [pwd] set verbose 0 @@ -107,7 +110,45 @@ proc test2 {} { puts "OK: test2: Modifications don't corrupt existing open handles" } +proc test3 {} { + # lxs said: Start with a relation in the file. Open, delete + # relation, add relation back, list relations. In 1.4 release + # code, got two back. + + global wd verbose + + exec cp $wd/test2.ini $wd/test1c.ini + set p [profile_init_path $wd/test1c.ini] + set sect {{test section 1} quux} + + set v [profile_get_values $p $sect] + set v1 [lindex $v 0] + if $verbose { puts "Old values: $v" } + profile_clear_relation $p $sect + if $verbose { puts "Cleared." } + # profile_get_values raises an exception if no data is there; so if + # it succeeds, the test fails. + catch { + set v [profile_get_values $p $sect] + if $verbose { puts "New values: $v" } + puts stderr "Error: test3: Clearing relation didn't get rid of all values." + exit 1 + } + if $verbose { puts "Adding back $v1 ..." } + profile_add_relation $p $sect $v1 + set v [profile_get_values $p $sect] + if $verbose { puts "New values: $v" } + if [llength $v]!=1 { + puts stderr "Error: test3: Adding one entry after clearing relation leaves [llength $v] entries." + exit 1 + } + profile_abandon $p + file delete $wd/test1c.ini + puts "OK: test3: Clearing relation and adding one entry yields correct count." +} + test1 test2 +test3 exit 0 diff --git a/src/util/profile/prof_tree.c b/src/util/profile/prof_tree.c index 4dec26f38..b014e245d 100644 --- a/src/util/profile/prof_tree.c +++ b/src/util/profile/prof_tree.c @@ -574,6 +574,8 @@ get_new_file: skip_num--; continue; } + if (p->deleted) + continue; break; } iter->num++;