Fix off-by-one that got us stuck on 0-byte files.
This commit is contained in:
@@ -218,9 +218,7 @@ static struct file *file_next() {
|
|||||||
|
|
||||||
if (iter->next == &file_head) {
|
if (iter->next == &file_head) {
|
||||||
iter = iter->next->next;
|
iter = iter->next->next;
|
||||||
if (!(++rounds % 100)) {
|
++rounds;
|
||||||
stats_print();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
iter = iter->next;
|
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 remaining_len = total_len - conn->offset;
|
||||||
size_t rnd;
|
size_t rnd;
|
||||||
rand_fill(&rnd, sizeof(rnd));
|
rand_fill(&rnd, sizeof(rnd));
|
||||||
rnd %= total_len;
|
rnd = (rnd % total_len) + 1;
|
||||||
return rnd > remaining_len ? remaining_len : rnd;
|
return rnd > remaining_len ? remaining_len : rnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,7 +403,9 @@ int main(int argc, char *argv[]) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
while (!shutdown_flag) {
|
while (!shutdown_flag) {
|
||||||
cycle++;
|
if (!(++cycle % 100)) {
|
||||||
|
stats_print();
|
||||||
|
}
|
||||||
conn_cycle();
|
conn_cycle();
|
||||||
conn_fill();
|
conn_fill();
|
||||||
nanosleep(&ts, NULL);
|
nanosleep(&ts, NULL);
|
||||||
|
|||||||
Reference in New Issue
Block a user