Skip to content

Commit 303fc17

Browse files
committed
Fix another stupid bug introduced by 09a1be3
1 parent 170f528 commit 303fc17

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

src/bench-targets.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,9 @@ int main(int argc, char *argv[])
5757
printf("time %.2fs\n", secs);
5858
printf("speed %ldk/s\n", (long)(naddr / secs) / 1000);
5959

60+
if(target_gen_progress() <= 0.999f) {
61+
printf("DID NOT FINISH?!\n");
62+
return 1;
63+
}
6064
return 0;
6165
}

src/target-gen.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,9 @@ static void fill_cache(void)
401401
iter_min = (targets_last_i + 1) % targets_i;
402402
do {
403403
const unsigned int iter_max = unfinished_max;
404-
// update unfinished_max along the way, for the next iteration
405-
unfinished_max = 0;
404+
// update unfinished_max along the way, for the next iteration.
405+
// take the targets we haven't looked at into account when iterating partially.
406+
unfinished_max = iter_min;
406407
assert(iter_min < iter_max);
407408
for(unsigned int i = iter_min; i < iter_max; i++) {
408409
if(targets[i].done)
@@ -423,6 +424,12 @@ static void fill_cache(void)
423424
}
424425
iter_min = 0;
425426
} while(unfinished_max > 0);
427+
428+
// if we get here, we must be done
429+
for(unsigned int i = 0; i < targets_i; i++) {
430+
assert(targets[i].done);
431+
assert(targets[i].delayed_start == 0);
432+
}
426433
}
427434

428435
static inline uint64_t read_be64(const void *ptr)

util/ci-test4.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,22 @@ done
112112

113113
##
114114

115+
# differing sizes and bigger than the internal buffer
116+
printf '%s\n' >in.txt \
117+
f00::x f01::xx f02::xxx f03::xxxx
118+
119+
for opt in 1 0; do
120+
121+
notee=1 try --randomize-hosts $opt --print-hosts @in.txt
122+
check_out "^f00::2"
123+
check_out "^f01::24"
124+
check_out "^f02::246"
125+
check_out "^f03::2468"
126+
127+
done
128+
129+
##
130+
115131
try --icmp 3ffe::/48
116132
check_out "tremendous amount of time"
117133

0 commit comments

Comments
 (0)