From 98741d91892b68e6b6046ac563e11990498104e4 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Wed, 9 Mar 2016 15:17:08 -0800 Subject: [PATCH] Fix off-by-one that got us stuck on 0-byte files. --- stutterfuzz.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stutterfuzz.c b/stutterfuzz.c index a9ad02d..1fcb906 100644 --- a/stutterfuzz.c +++ b/stutterfuzz.c @@ -218,9 +218,7 @@ static struct file *file_next() { if (iter->next == &file_head) { iter = iter->next->next; - if (!(++rounds % 100)) { - stats_print(); - } + ++rounds; } else { iter = iter->next; } @@ -232,7 +230,7 @@ static size_t conn_get_split(struct conn *conn) { size_t remaining_len = total_len - conn->offset; size_t rnd; rand_fill(&rnd, sizeof(rnd)); - rnd %= total_len; + rnd = (rnd % total_len) + 1; return rnd > remaining_len ? remaining_len : rnd; } @@ -405,7 +403,9 @@ int main(int argc, char *argv[]) { }; while (!shutdown_flag) { - cycle++; + if (!(++cycle % 100)) { + stats_print(); + } conn_cycle(); conn_fill(); nanosleep(&ts, NULL);