Skip to content

Commit

Permalink
Auto adjustment of test-end condition for file-transfer
Browse files Browse the repository at this point in the history
In file transfer mode (-F), if no test-end condition is set,
(bytes, blocks, duration), it will automatically adjsut it to
file size (in bytes).
  • Loading branch information
hanvari committed Jul 3, 2021
1 parent 703bf42 commit 6af2ccc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/iperf_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1564,6 +1564,23 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
if (!rate_flag)
test->settings->rate = test->protocol->id == Pudp ? UDP_RATE : 0;

/* if no bytes or blocks specified, nor a duration_flag, and we have -F,
** get the file-size as the bytes count to be transferred
*/
if (test->settings->bytes == 0 &&
test->settings->blocks == 0 &&
! duration_flag &&
test->diskfile_name != (char*) 0 &&
test->role == 'c'
){
struct stat st;
stat(test->diskfile_name, &st);
iperf_size_t file_bytes = st.st_size;
test->settings->bytes = file_bytes;
if (test->debug)
printf("End condition set to file-size: %d bytes\n", test->settings->bytes);
}

if ((test->settings->bytes != 0 || test->settings->blocks != 0) && ! duration_flag)
test->duration = 0;

Expand Down

0 comments on commit 6af2ccc

Please sign in to comment.