Skip to content

Commit

Permalink
Fix: Avoid spamming stdout (and JSON output) with a warning.
Browse files Browse the repository at this point in the history
Fixes esnet#1223.
  • Loading branch information
bmah888 committed Nov 11, 2021
1 parent a8e0787 commit a071a8c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/iperf_api.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* iperf, Copyright (c) 2014-2020, The Regents of the University of
* iperf, Copyright (c) 2014-2021, The Regents of the University of
* California, through Lawrence Berkeley National Laboratory (subject
* to receipt of any required approvals from the U.S. Dept. of
* Energy). All rights reserved.
Expand Down Expand Up @@ -60,6 +60,8 @@ typedef uint64_t iperf_size_t;
#define DEFAULT_NO_MSG_RCVD_TIMEOUT 120000
#define MIN_NO_MSG_RCVD_TIMEOUT 100

#define WARN_STR_LEN 128

/* short option equivalents, used to support options that only have long form */
#define OPT_SCTP 1
#define OPT_LOGFILE 2
Expand Down
14 changes: 9 additions & 5 deletions src/iperf_udp.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* iperf, Copyright (c) 2014-2020, The Regents of the University of
* iperf, Copyright (c) 2014-2021, The Regents of the University of
* California, through Lawrence Berkeley National Laboratory (subject
* to receipt of any required approvals from the U.S. Dept. of
* Energy). All rights reserved.
Expand Down Expand Up @@ -403,9 +403,11 @@ iperf_udp_accept(struct iperf_test *test)
*/
if (rc > 0) {
if (test->settings->socket_bufsize == 0) {
char str[WARN_STR_LEN];
int bufsize = test->settings->blksize + UDP_BUFFER_EXTRA;
printf("Increasing socket buffer size to %d\n",
bufsize);
snprintf(str, sizeof(str), "Increasing socket buffer size to %d",
bufsize);
warning(str);
test->settings->socket_bufsize = bufsize;
rc = iperf_udp_buffercheck(test, s);
if (rc < 0)
Expand Down Expand Up @@ -515,9 +517,11 @@ iperf_udp_connect(struct iperf_test *test)
*/
if (rc > 0) {
if (test->settings->socket_bufsize == 0) {
char str[WARN_STR_LEN];
int bufsize = test->settings->blksize + UDP_BUFFER_EXTRA;
printf("Increasing socket buffer size to %d\n",
bufsize);
snprintf(str, sizeof(str), "Increasing socket buffer size to %d",
bufsize);
warning(str);
test->settings->socket_bufsize = bufsize;
rc = iperf_udp_buffercheck(test, s);
if (rc < 0)
Expand Down

0 comments on commit a071a8c

Please sign in to comment.