Skip to content

Commit

Permalink
Return client_api error codes, even with json output enabled
Browse files Browse the repository at this point in the history
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 #1405 .
  • Loading branch information
matt9j committed May 20, 2023
1 parent b3e1ba3 commit 2da06de
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/iperf_client_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,10 +708,6 @@ iperf_run_client(struct iperf_test * test)
if (test->json_output) {
cJSON_AddStringToObject(test->json_top, "error", iperf_strerror(i_errno));
iperf_json_finish(test);
iflush(test);
// Return 0 and not -1 since all terminating function were done here.
// Also prevents error message logging outside the already closed JSON output.
return 0;
}
iflush(test);
return -1;
Expand Down

0 comments on commit 2da06de

Please sign in to comment.