Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exit Value of iperf while using --json output #1405

Closed
hajoha opened this issue Oct 14, 2022 · 1 comment · Fixed by #1523
Closed

Exit Value of iperf while using --json output #1405

hajoha opened this issue Oct 14, 2022 · 1 comment · Fixed by #1523
Labels
bug:json Bugs related to JSON output

Comments

@hajoha
Copy link

hajoha commented Oct 14, 2022

Context

  • Version of iperf3:
    since version 3.11

  • Hardware:
    any

  • Operating system (and distribution, if any):
    any

  • Other relevant information (for example, non-default compilers,
    libraries, cross-compiling, etc.):
    nothing just plain ./configure;sudo make;sudo make install

Bug Report

  • Expected Behavior
    when calling iperf (and the server is not reachable) with iperf3 -c localhost --json it's exit value should be 1
    when calling iperf (and the server is not reachable) with iperf3 -c localhost it's exit value is 1

  • Actual Behavior
    when calling iperf (and the server is not reachable) with iperf3 -c localhost --json it's exit value is 0
    when calling iperf (and the server is not reachable) with iperf3 -c localhost it's exit value is 1

  • Possible Solution
    change the cleanup_and_fail in iperf_client_api.c to

cleanup_and_fail:
    iperf_client_end(test);
    iflush(test);
    return -1;
@bmah888 bmah888 added the bug:json Bugs related to JSON output label Oct 17, 2022
@bmah888
Copy link
Contributor

bmah888 commented Oct 17, 2022

Reproduced this behavior on iperf-3.12, and you're right, it shouldn't do that.

@bmah888 bmah888 linked a pull request Oct 19, 2022 that will close this issue
matt9j added a commit to matt9j/iperf that referenced this issue May 20, 2023
Previously on error, the client API would return 0 (success) in the
cleanup and fail error handling path when outputting json to avoid
double-closing the JSON output. With iperf_json_finish now idempotent,
the client api can faithfully return an error when it fails, and the
calling context will not double-close the output if it has already
been closed.

This addresses esnet#1405 .
matt9j added a commit to matt9j/iperf that referenced this issue May 20, 2023
Previously on error, the client API would return 0 (success) in the
cleanup and fail error handling path when outputting json to avoid
double-closing the JSON output. With iperf_json_finish now idempotent,
the client api can faithfully return an error when it fails, and the
calling context will not double-close the output if it has already
been closed.

This addresses esnet#1405 .
@bmah888 bmah888 linked a pull request Jul 3, 2023 that will close this issue
coolshou pushed a commit to coolshou/iperf that referenced this issue Jul 13, 2023
Previously on error, the client API would return 0 (success) in the
cleanup and fail error handling path when outputting json to avoid
double-closing the JSON output. With iperf_json_finish now idempotent,
the client api can faithfully return an error when it fails, and the
calling context will not double-close the output if it has already
been closed.

This addresses esnet#1405 .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:json Bugs related to JSON output
Projects
None yet
2 participants