diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:27:01 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:27:01 +0000 |
commit | dc990bc79d0d7663bd6e775d2253e158b74686b4 (patch) | |
tree | 8e3731e353efeffbf1319921c34e579fa403033b /src/iperf_error.c | |
parent | Releasing progress-linux version 3.16-1~progress7.99u1. (diff) | |
download | iperf3-dc990bc79d0d7663bd6e775d2253e158b74686b4.tar.xz iperf3-dc990bc79d0d7663bd6e775d2253e158b74686b4.zip |
Merging upstream version 3.17.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/iperf_error.c')
-rw-r--r-- | src/iperf_error.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/iperf_error.c b/src/iperf_error.c index 6426554..0fedf31 100644 --- a/src/iperf_error.c +++ b/src/iperf_error.c @@ -47,10 +47,6 @@ iperf_err(struct iperf_test *test, const char *format, ...) struct tm *ltm = NULL; char *ct = NULL; - if (pthread_mutex_lock(&(test->print_mutex)) != 0) { - perror("iperf_err: pthread_mutex_lock"); - } - /* Timestamp if requested */ if (test != NULL && test->timestamps) { time(&now); @@ -64,6 +60,10 @@ iperf_err(struct iperf_test *test, const char *format, ...) if (test != NULL && test->json_output && test->json_top != NULL) cJSON_AddStringToObject(test->json_top, "error", str); else { + if (pthread_mutex_lock(&(test->print_mutex)) != 0) { + perror("iperf_err: pthread_mutex_lock"); + } + if (test && test->outfile && test->outfile != stdout) { if (ct) { fprintf(test->outfile, "%s", ct); @@ -76,12 +76,13 @@ iperf_err(struct iperf_test *test, const char *format, ...) } fprintf(stderr, "iperf3: %s\n", str); } - } - va_end(argp); - if (pthread_mutex_unlock(&(test->print_mutex)) != 0) { - perror("iperf_err: pthread_mutex_unlock"); + if (pthread_mutex_unlock(&(test->print_mutex)) != 0) { + perror("iperf_err: pthread_mutex_unlock"); + } + } + va_end(argp); } /* Do a printf to stderr or log file as appropriate, then exit. */ @@ -94,10 +95,6 @@ iperf_errexit(struct iperf_test *test, const char *format, ...) struct tm *ltm = NULL; char *ct = NULL; - if (pthread_mutex_lock(&(test->print_mutex)) != 0) { - perror("iperf_errexit: pthread_mutex_lock"); - } - /* Timestamp if requested */ if (test != NULL && test->timestamps) { time(&now); @@ -113,7 +110,11 @@ iperf_errexit(struct iperf_test *test, const char *format, ...) cJSON_AddStringToObject(test->json_top, "error", str); } iperf_json_finish(test); - } else + } else { + if (pthread_mutex_lock(&(test->print_mutex)) != 0) { + perror("iperf_errexit: pthread_mutex_lock"); + } + if (test && test->outfile && test->outfile != stdout) { if (ct) { fprintf(test->outfile, "%s", ct); @@ -127,8 +128,9 @@ iperf_errexit(struct iperf_test *test, const char *format, ...) fprintf(stderr, "iperf3: %s\n", str); } - if (pthread_mutex_unlock(&(test->print_mutex)) != 0) { - perror("iperf_errexit: pthread_mutex_unlock"); + if (pthread_mutex_unlock(&(test->print_mutex)) != 0) { + perror("iperf_errexit: pthread_mutex_unlock"); + } } va_end(argp); @@ -166,7 +168,7 @@ iperf_strerror(int int_errno) snprintf(errstr, len, "some option you are trying to set is client only"); break; case IEDURATION: - snprintf(errstr, len, "test duration too long (maximum = %d seconds)", MAX_TIME); + snprintf(errstr, len, "test duration valid values are 0 to %d seconds", MAX_TIME); break; case IENUMSTREAMS: snprintf(errstr, len, "number of parallel streams too large (maximum = %d)", MAX_STREAMS); |