From ed02b719a9322845f7e6db74449c754eeef71627 Mon Sep 17 00:00:00 2001 From: Dane Murphy Date: Wed, 17 Apr 2024 21:26:37 -0700 Subject: [PATCH 1/6] add time flag for the iperf server process --- output.json | 126 +++++++++++++++++++++++++++++++++++++++++ src/iperf.h | 1 + src/iperf_api.c | 14 ++++- src/iperf_api.h | 1 + src/iperf_locale.c | 2 + src/iperf_server_api.c | 4 ++ 6 files changed, 146 insertions(+), 2 deletions(-) create mode 100644 output.json diff --git a/output.json b/output.json new file mode 100644 index 000000000..b9a070733 --- /dev/null +++ b/output.json @@ -0,0 +1,126 @@ +{ + "start": { + "connected": [{ + "socket": 5, + "local_host": "127.0.0.1", + "local_port": 49450, + "remote_host": "127.0.0.1", + "remote_port": 5201 + }], + "version": "iperf 3.16+", + "system_info": "Linux windows-nexus 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64", + "timestamp": { + "time": "Thu, 18 Apr 2024 02:21:31 GMT", + "timesecs": 1713406891 + }, + "connecting_to": { + "host": "127.0.0.1", + "port": 5201 + }, + "cookie": "o6ry6dakh6fsbzqw5qeoundkyc45ofkdti4m", + "tcp_mss_default": 32768, + "target_bitrate": 1000000, + "fq_rate": 0, + "sock_bufsize": 0, + "sndbuf_actual": 16384, + "rcvbuf_actual": 131072, + "test_start": { + "protocol": "TCP", + "num_streams": 1, + "blksize": 131072, + "omit": 0, + "duration": 10, + "bytes": 0, + "blocks": 0, + "reverse": 0, + "tos": 0, + "target_bitrate": 1000000, + "bidir": 0, + "fqrate": 0, + "interval": 1 + } + }, + "intervals": [{ + "streams": [{ + "socket": 5, + "start": 0, + "end": 1.00023, + "seconds": 1.0002299547195435, + "bytes": 131072, + "bits_per_second": 1048334.9304350842, + "retransmits": 0, + "snd_cwnd": 654830, + "snd_wnd": 327424, + "rtt": 14, + "rttvar": 14, + "pmtu": 65535, + "omitted": false, + "sender": true + }], + "sum": { + "start": 0, + "end": 1.00023, + "seconds": 1.0002299547195435, + "bytes": 131072, + "bits_per_second": 1048334.9304350842, + "retransmits": 0, + "omitted": false, + "sender": true + } + }], + "end": { + "streams": [{ + "sender": { + "socket": 5, + "start": 0, + "end": 1.00023, + "seconds": 1.00023, + "bytes": 131072, + "bits_per_second": 1048334.8829769153, + "retransmits": 0, + "max_snd_cwnd": 654830, + "max_snd_wnd": 327424, + "max_rtt": 14, + "min_rtt": 14, + "mean_rtt": 14, + "sender": true + }, + "receiver": { + "socket": 5, + "start": 0, + "end": 1.000388, + "seconds": 1.00023, + "bytes": 131072, + "bits_per_second": 1048169.3103076005, + "sender": true + } + }], + "sum_sent": { + "start": 0, + "end": 1.00023, + "seconds": 1.00023, + "bytes": 131072, + "bits_per_second": 1048334.8829769153, + "retransmits": 0, + "sender": true + }, + "sum_received": { + "start": 0, + "end": 1.000388, + "seconds": 1.000388, + "bytes": 131072, + "bits_per_second": 1048169.3103076005, + "sender": true + }, + "cpu_utilization_percent": { + "host_total": 100.19931842091853, + "host_user": 99.5489109421317, + "host_system": 0.650407478786825, + "remote_total": 0.022490801262283724, + "remote_user": 0, + "remote_system": 0.022490801262283724 + }, + "sender_tcp_congestion": "cubic", + "receiver_tcp_congestion": "cubic" + } +} \ No newline at end of file diff --git a/src/iperf.h b/src/iperf.h index 527e549ed..f169cc4bd 100644 --- a/src/iperf.h +++ b/src/iperf.h @@ -293,6 +293,7 @@ struct iperf_test int server_port; int omit; /* duration of omit period (-O flag) */ int duration; /* total duration of test (-t flag) */ + int server_duration; /* maximum possible duration of test as enforced by the server (--server-time flag) */ char *diskfile_name; /* -F option */ int affinity, server_affinity; /* -A option */ #if defined(HAVE_CPUSET_SETAFFINITY) diff --git a/src/iperf_api.c b/src/iperf_api.c index 4c73e8328..c1edbc262 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -1080,7 +1080,8 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv) {"udp", no_argument, NULL, 'u'}, {"bitrate", required_argument, NULL, 'b'}, {"bandwidth", required_argument, NULL, 'b'}, - {"server-bitrate-limit", required_argument, NULL, OPT_SERVER_BITRATE_LIMIT}, + {"server-bitrate-limit", required_argument, NULL, OPT_SERVER_BITRATE_LIMIT}, + {"server-time", required_argument, NULL, OPT_SERVER_TIME}, {"time", required_argument, NULL, 't'}, {"bytes", required_argument, NULL, 'n'}, {"blockcount", required_argument, NULL, 'k'}, @@ -1164,7 +1165,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv) int rcv_timeout_in = 0; blksize = 0; - server_flag = client_flag = rate_flag = duration_flag = rcv_timeout_flag = snd_timeout_flag =0; + server_flag = client_flag = rate_flag = duration_flag = rcv_timeout_flag = snd_timeout_flag = 0; #if defined(HAVE_SSL) char *client_username = NULL, *client_rsa_public_key = NULL, *server_rsa_private_key = NULL; FILE *ptr_file; @@ -1312,6 +1313,14 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv) test->settings->bitrate_limit = unit_atof_rate(optarg); server_flag = 1; break; + case OPT_SERVER_TIME: + test->server_duration = atoi(optarg); + if (test->server_duration > MAX_TIME || test->server_duration < 0) { + i_errno = IEDURATION; + return -1; + } + server_flag = 1; + break; case 't': test->duration = atoi(optarg); if (test->duration > MAX_TIME || test->duration < 0) { @@ -2929,6 +2938,7 @@ iperf_defaults(struct iperf_test *testp) testp->omit = OMIT; testp->duration = DURATION; + testp->server_duration = -1; testp->diskfile_name = (char*) 0; testp->affinity = -1; testp->server_affinity = -1; diff --git a/src/iperf_api.h b/src/iperf_api.h index 131314243..32cea7e0f 100644 --- a/src/iperf_api.h +++ b/src/iperf_api.h @@ -101,6 +101,7 @@ typedef atomic_uint_fast64_t atomic_iperf_size_t; #define OPT_JSON_STREAM 28 #define OPT_SND_TIMEOUT 29 #define OPT_USE_PKCS1_PADDING 30 +#define OPT_SERVER_TIME 31 /* states */ #define TEST_START 1 diff --git a/src/iperf_locale.c b/src/iperf_locale.c index 9d94e0234..85b0bc628 100644 --- a/src/iperf_locale.c +++ b/src/iperf_locale.c @@ -149,6 +149,8 @@ const char usage_longstr[] = "Usage: iperf3 [-s|-c host] [options]\n" " --time-skew-threshold time skew threshold (in seconds) between the server\n" " and client during the authentication process\n" " --use-pkcs1-padding use pkcs1 padding at your own risk\n" + " --server-time time in seconds to transmit for. selected when \n" + " value is less than client's duration.\n" #endif //HAVE_SSL "Client specific:\n" " -c, --client [%%] run in client mode, connecting to \n" diff --git a/src/iperf_server_api.c b/src/iperf_server_api.c index 7d512081c..a5f73aaec 100644 --- a/src/iperf_server_api.c +++ b/src/iperf_server_api.c @@ -341,6 +341,10 @@ create_server_timers(struct iperf_test * test) cd.p = test; test->timer = test->stats_timer = test->reporter_timer = NULL; if (test->duration != 0 ) { + if (test->server_duration > 0 && test->server_duration < test->duration) { + test->duration = test->server_duration; + grace_period = 0; + } test->done = 0; test->timer = tmr_create(&now, server_timer_proc, cd, (test->duration + test->omit + grace_period) * SEC_TO_US, 0); if (test->timer == NULL) { From d40545b7dff092a0082a61ec302aa1c10b46b3d5 Mon Sep 17 00:00:00 2001 From: Dane Murphy Date: Thu, 18 Apr 2024 17:18:53 -0700 Subject: [PATCH 2/6] remove output from file --- output.json | 126 ---------------------------------------------------- 1 file changed, 126 deletions(-) delete mode 100644 output.json diff --git a/output.json b/output.json deleted file mode 100644 index b9a070733..000000000 --- a/output.json +++ /dev/null @@ -1,126 +0,0 @@ -{ - "start": { - "connected": [{ - "socket": 5, - "local_host": "127.0.0.1", - "local_port": 49450, - "remote_host": "127.0.0.1", - "remote_port": 5201 - }], - "version": "iperf 3.16+", - "system_info": "Linux windows-nexus 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64", - "timestamp": { - "time": "Thu, 18 Apr 2024 02:21:31 GMT", - "timesecs": 1713406891 - }, - "connecting_to": { - "host": "127.0.0.1", - "port": 5201 - }, - "cookie": "o6ry6dakh6fsbzqw5qeoundkyc45ofkdti4m", - "tcp_mss_default": 32768, - "target_bitrate": 1000000, - "fq_rate": 0, - "sock_bufsize": 0, - "sndbuf_actual": 16384, - "rcvbuf_actual": 131072, - "test_start": { - "protocol": "TCP", - "num_streams": 1, - "blksize": 131072, - "omit": 0, - "duration": 10, - "bytes": 0, - "blocks": 0, - "reverse": 0, - "tos": 0, - "target_bitrate": 1000000, - "bidir": 0, - "fqrate": 0, - "interval": 1 - } - }, - "intervals": [{ - "streams": [{ - "socket": 5, - "start": 0, - "end": 1.00023, - "seconds": 1.0002299547195435, - "bytes": 131072, - "bits_per_second": 1048334.9304350842, - "retransmits": 0, - "snd_cwnd": 654830, - "snd_wnd": 327424, - "rtt": 14, - "rttvar": 14, - "pmtu": 65535, - "omitted": false, - "sender": true - }], - "sum": { - "start": 0, - "end": 1.00023, - "seconds": 1.0002299547195435, - "bytes": 131072, - "bits_per_second": 1048334.9304350842, - "retransmits": 0, - "omitted": false, - "sender": true - } - }], - "end": { - "streams": [{ - "sender": { - "socket": 5, - "start": 0, - "end": 1.00023, - "seconds": 1.00023, - "bytes": 131072, - "bits_per_second": 1048334.8829769153, - "retransmits": 0, - "max_snd_cwnd": 654830, - "max_snd_wnd": 327424, - "max_rtt": 14, - "min_rtt": 14, - "mean_rtt": 14, - "sender": true - }, - "receiver": { - "socket": 5, - "start": 0, - "end": 1.000388, - "seconds": 1.00023, - "bytes": 131072, - "bits_per_second": 1048169.3103076005, - "sender": true - } - }], - "sum_sent": { - "start": 0, - "end": 1.00023, - "seconds": 1.00023, - "bytes": 131072, - "bits_per_second": 1048334.8829769153, - "retransmits": 0, - "sender": true - }, - "sum_received": { - "start": 0, - "end": 1.000388, - "seconds": 1.000388, - "bytes": 131072, - "bits_per_second": 1048169.3103076005, - "sender": true - }, - "cpu_utilization_percent": { - "host_total": 100.19931842091853, - "host_user": 99.5489109421317, - "host_system": 0.650407478786825, - "remote_total": 0.022490801262283724, - "remote_user": 0, - "remote_system": 0.022490801262283724 - }, - "sender_tcp_congestion": "cubic", - "receiver_tcp_congestion": "cubic" - } -} \ No newline at end of file From f7f70d3a199cf364bb0804ff72eb7fbbd55cfe2d Mon Sep 17 00:00:00 2001 From: Dane Murphy Date: Sun, 21 Apr 2024 18:49:34 -0700 Subject: [PATCH 3/6] iterate on implementation, add some comments to explain code --- src/iperf_api.c | 6 +++--- src/iperf_api.h | 2 ++ src/iperf_client_api.c | 32 ++++++++++++++++++++++++++++---- src/iperf_server_api.c | 36 +++++++++++++++++++++++++++++------- 4 files changed, 62 insertions(+), 14 deletions(-) diff --git a/src/iperf_api.c b/src/iperf_api.c index c1edbc262..94be965af 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -892,7 +892,7 @@ void iperf_on_test_start(struct iperf_test *test) { if (test->json_output) { - cJSON_AddItemToObject(test->json_start, "test_start", iperf_json_printf("protocol: %s num_streams: %d blksize: %d omit: %d duration: %d bytes: %d blocks: %d reverse: %d tos: %d target_bitrate: %d bidir: %d fqrate: %d interval: %f", test->protocol->name, (int64_t) test->num_streams, (int64_t) test->settings->blksize, (int64_t) test->omit, (int64_t) test->duration, (int64_t) test->settings->bytes, (int64_t) test->settings->blocks, test->reverse?(int64_t)1:(int64_t)0, (int64_t) test->settings->tos, (int64_t) test->settings->rate, (int64_t) test->bidirectional, (uint64_t) test->settings->fqrate, test->stats_interval)); + cJSON_AddItemToObject(test->json_start, "test_start", iperf_json_printf("protocol: %s num_streams: %d blksize: %d omit: %d duration: %d server_duration: %d bytes: %d blocks: %d reverse: %d tos: %d target_bitrate: %d bidir: %d fqrate: %d interval: %f", test->protocol->name, (int64_t) test->num_streams, (int64_t) test->settings->blksize, (int64_t) test->omit, (int64_t) test->duration, (int64_t) test->settings->bytes, (int64_t) test->settings->blocks, test->reverse?(int64_t)1:(int64_t)0, (int64_t) test->settings->tos, (int64_t) test->settings->rate, (int64_t) test->bidirectional, (uint64_t) test->settings->fqrate, test->stats_interval)); } else { if (test->verbose) { if (test->settings->bytes) @@ -900,7 +900,7 @@ iperf_on_test_start(struct iperf_test *test) else if (test->settings->blocks) iperf_printf(test, test_start_blocks, test->protocol->name, test->num_streams, test->settings->blksize, test->omit, test->settings->blocks, test->settings->tos); else - iperf_printf(test, test_start_time, test->protocol->name, test->num_streams, test->settings->blksize, test->omit, test->duration, test->settings->tos); + iperf_printf(test, test_start_time, test->protocol->name, test->num_streams, test->settings->blksize, test->omit, test->server_duration > test->duration ? test->server_duration : test->duration, test->settings->tos); } } if (test->json_stream) { @@ -2938,7 +2938,7 @@ iperf_defaults(struct iperf_test *testp) testp->omit = OMIT; testp->duration = DURATION; - testp->server_duration = -1; + testp->server_duration = 0; testp->diskfile_name = (char*) 0; testp->affinity = -1; testp->server_affinity = -1; diff --git a/src/iperf_api.h b/src/iperf_api.h index 32cea7e0f..adae45cd0 100644 --- a/src/iperf_api.h +++ b/src/iperf_api.h @@ -476,6 +476,8 @@ enum { IEPTHREADJOIN=152, // Unable to join thread (check perror) IEPTHREADATTRINIT=153, // Unable to initialize thread attribute (check perror) IEPTHREADATTRDESTROY=154, // Unable to destroy thread attribute (check perror) + IESENDSERVERDURATION=155, // Unable to send the server's maximum measurement duration + IERECVSERVERDURATION=156, // Unable to receive the server's maximum measurement duration /* Stream errors */ IECREATESTREAM = 200, // Unable to create a new stream (check herror/perror) IEINITSTREAM = 201, // Unable to initialize stream (check herror/perror) diff --git a/src/iperf_client_api.c b/src/iperf_client_api.c index 7ad4c939b..ddb4bd35e 100644 --- a/src/iperf_client_api.c +++ b/src/iperf_client_api.c @@ -203,14 +203,26 @@ create_client_timers(struct iperf_test * test) } cd.p = test; test->timer = test->stats_timer = test->reporter_timer = NULL; - if (test->duration != 0) { - test->done = 0; - test->timer = tmr_create(&now, test_timer_proc, cd, ( test->duration + test->omit ) * SEC_TO_US, 0); + + int duration = test->duration; + if (duration != 0) { + /** + * The duration of the measurement should only be overridden if it exceeds the duration set by the server or + * of no duration is set on the server. + * + */ + if (test->server_duration > 0 && test->server_duration < duration) { + duration = test->server_duration; + } + + test->done = 0; + test->timer = tmr_create(&now, test_timer_proc, cd, (duration + test->omit) * SEC_TO_US, 0); if (test->timer == NULL) { i_errno = IEINITTEST; return -1; - } + } } + if (test->stats_interval != 0) { test->stats_timer = tmr_create(&now, client_stats_timer_proc, cd, test->stats_interval * SEC_TO_US, 1); if (test->stats_timer == NULL) { @@ -426,6 +438,18 @@ iperf_connect(struct iperf_test *test) return -1; } + /** + * If the server has a value set for the --server-time flag, the client will read it here and adjust its measurement time accordingly. + * If the value is 0, then the measurement will run for the duration that the client has set. + */ + char server_duration_str[15] = ""; + if (Nread(test->ctrl_sck, server_duration_str, sizeof(server_duration_str), Ptcp) != sizeof(server_duration_str)) + { + i_errno = IERECVSERVERDURATION; + return -1; + } + test->server_duration = atoi(server_duration_str); + FD_SET(test->ctrl_sck, &test->read_set); if (test->ctrl_sck > test->max_fd) test->max_fd = test->ctrl_sck; diff --git a/src/iperf_server_api.c b/src/iperf_server_api.c index a5f73aaec..88c3c2448 100644 --- a/src/iperf_server_api.c +++ b/src/iperf_server_api.c @@ -175,8 +175,23 @@ iperf_accept(struct iperf_test *test) i_errno = IERECVCOOKIE; goto error_handling; } - FD_SET(test->ctrl_sck, &test->read_set); - if (test->ctrl_sck > test->max_fd) test->max_fd = test->ctrl_sck; + + /** + * If the server has a value set for the --server-time flag, send it to the client + * so that it can adjust its measurement time accordingly. If the value was not set + * via the flag, then the client will see a value of 0, which means that the server + * does not have a maximum measurement time. + */ + char server_duration_str[15] = ""; + sprintf(server_duration_str, "%d", test->server_duration); + + if (Nwrite(test->ctrl_sck, server_duration_str, sizeof(server_duration_str), Ptcp) < 0) { + i_errno = IESENDSERVERDURATION; + return -1; + } + + FD_SET(test->ctrl_sck, &test->read_set); + if (test->ctrl_sck > test->max_fd) test->max_fd = test->ctrl_sck; if (iperf_set_send_state(test, PARAM_EXCHANGE) != 0) goto error_handling; @@ -340,13 +355,20 @@ create_server_timers(struct iperf_test * test) } cd.p = test; test->timer = test->stats_timer = test->reporter_timer = NULL; - if (test->duration != 0 ) { - if (test->server_duration > 0 && test->server_duration < test->duration) { - test->duration = test->server_duration; - grace_period = 0; + + int duration = test->duration; + if (duration != 0 ) { + /** + * The duration of the measurement should only be overridden if it exceeds the duration set by the server or + * of no duration is set on the server. + * + */ + if (test->server_duration > 0 && test->server_duration < duration) { + duration = test->server_duration; } + test->done = 0; - test->timer = tmr_create(&now, server_timer_proc, cd, (test->duration + test->omit + grace_period) * SEC_TO_US, 0); + test->timer = tmr_create(&now, server_timer_proc, cd, (duration + test->omit + grace_period) * SEC_TO_US, 0); if (test->timer == NULL) { i_errno = IEINITTEST; return -1; From 2cb935ce98a12b16e4b64d6d335839ef41c6b3ac Mon Sep 17 00:00:00 2001 From: Dane Murphy Date: Sun, 21 Apr 2024 19:03:11 -0700 Subject: [PATCH 4/6] fix json output --- src/iperf_api.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/iperf_api.c b/src/iperf_api.c index 94be965af..c868f9177 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -892,7 +892,7 @@ void iperf_on_test_start(struct iperf_test *test) { if (test->json_output) { - cJSON_AddItemToObject(test->json_start, "test_start", iperf_json_printf("protocol: %s num_streams: %d blksize: %d omit: %d duration: %d server_duration: %d bytes: %d blocks: %d reverse: %d tos: %d target_bitrate: %d bidir: %d fqrate: %d interval: %f", test->protocol->name, (int64_t) test->num_streams, (int64_t) test->settings->blksize, (int64_t) test->omit, (int64_t) test->duration, (int64_t) test->settings->bytes, (int64_t) test->settings->blocks, test->reverse?(int64_t)1:(int64_t)0, (int64_t) test->settings->tos, (int64_t) test->settings->rate, (int64_t) test->bidirectional, (uint64_t) test->settings->fqrate, test->stats_interval)); + cJSON_AddItemToObject(test->json_start, "test_start", iperf_json_printf("protocol: %s num_streams: %d blksize: %d omit: %d duration: %d server_duration: %d bytes: %d blocks: %d reverse: %d tos: %d target_bitrate: %d bidir: %d fqrate: %d interval: %f", test->protocol->name, (int64_t) test->num_streams, (int64_t) test->settings->blksize, (int64_t) test->omit, (int64_t) test->duration, (int64_t) test->server_duration, (int64_t) test->settings->bytes, (int64_t) test->settings->blocks, test->reverse?(int64_t)1:(int64_t)0, (int64_t) test->settings->tos, (int64_t) test->settings->rate, (int64_t) test->bidirectional, (uint64_t) test->settings->fqrate, test->stats_interval)); } else { if (test->verbose) { if (test->settings->bytes) @@ -900,7 +900,7 @@ iperf_on_test_start(struct iperf_test *test) else if (test->settings->blocks) iperf_printf(test, test_start_blocks, test->protocol->name, test->num_streams, test->settings->blksize, test->omit, test->settings->blocks, test->settings->tos); else - iperf_printf(test, test_start_time, test->protocol->name, test->num_streams, test->settings->blksize, test->omit, test->server_duration > test->duration ? test->server_duration : test->duration, test->settings->tos); + iperf_printf(test, test_start_time, test->protocol->name, test->num_streams, test->settings->blksize, test->omit, (test->server_duration > 0 && test->duration > test->server_duration) ? test->server_duration : test->duration, test->settings->tos); } } if (test->json_stream) { From 98e915e0864c5f5a223f089135849af68f52d023 Mon Sep 17 00:00:00 2001 From: Dane Murphy Date: Sun, 21 Apr 2024 19:09:10 -0700 Subject: [PATCH 5/6] typo --- src/iperf_client_api.c | 4 ++-- src/iperf_server_api.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/iperf_client_api.c b/src/iperf_client_api.c index ddb4bd35e..2896e4589 100644 --- a/src/iperf_client_api.c +++ b/src/iperf_client_api.c @@ -208,7 +208,7 @@ create_client_timers(struct iperf_test * test) if (duration != 0) { /** * The duration of the measurement should only be overridden if it exceeds the duration set by the server or - * of no duration is set on the server. + * if no duration is set on the server. * */ if (test->server_duration > 0 && test->server_duration < duration) { @@ -220,7 +220,7 @@ create_client_timers(struct iperf_test * test) if (test->timer == NULL) { i_errno = IEINITTEST; return -1; - } + } } if (test->stats_interval != 0) { diff --git a/src/iperf_server_api.c b/src/iperf_server_api.c index 88c3c2448..e286c8c6e 100644 --- a/src/iperf_server_api.c +++ b/src/iperf_server_api.c @@ -360,7 +360,7 @@ create_server_timers(struct iperf_test * test) if (duration != 0 ) { /** * The duration of the measurement should only be overridden if it exceeds the duration set by the server or - * of no duration is set on the server. + * if no duration is set on the server. * */ if (test->server_duration > 0 && test->server_duration < duration) { From 07405264d9d8d84c5df19c257d8785023cbbd537 Mon Sep 17 00:00:00 2001 From: Dane Murphy Date: Wed, 5 Jun 2024 08:01:48 -0700 Subject: [PATCH 6/6] use goto for error handling --- src/iperf_server_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/iperf_server_api.c b/src/iperf_server_api.c index e286c8c6e..aa13d99f9 100644 --- a/src/iperf_server_api.c +++ b/src/iperf_server_api.c @@ -187,7 +187,7 @@ iperf_accept(struct iperf_test *test) if (Nwrite(test->ctrl_sck, server_duration_str, sizeof(server_duration_str), Ptcp) < 0) { i_errno = IESENDSERVERDURATION; - return -1; + goto error_handling; } FD_SET(test->ctrl_sck, &test->read_set);