Skip to content

Commit

Permalink
Per reviewer comment - add parameter to the callback function and enh…
Browse files Browse the repository at this point in the history
…anced per PR #1805 (with rebase)
  • Loading branch information
davidBar-On committed Feb 8, 2025
1 parent 806a7ce commit 76c60ee
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/iperf.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ struct iperf_test
int verbose; /* -V option - verbose mode */
int json_output; /* -J option - JSON output */
int json_stream; /* --json-stream */
void (*json_callback) (char *); /* used by user apps to receive the JSON strings,
instead of writing them to the output file */
void (*json_callback) (struct iperf_test *, char *); /* allow user apps to receive the
JSON strings,instead of writing them to the output file */
int zerocopy; /* -Z option - use sendfile */
int debug; /* -d option - enable debug */
enum debug_level debug_level; /* -d option option - level of debug messages to show */
Expand Down
6 changes: 3 additions & 3 deletions src/iperf_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ iperf_set_test_json_stream(struct iperf_test *ipt, int json_stream)
}

void
iperf_set_test_json_callback(struct iperf_test *ipt, void (*callback)())
iperf_set_test_json_callback(struct iperf_test *ipt, void (*callback)(struct iperf_test *, char *))
{
ipt->json_callback = callback;
}
Expand Down Expand Up @@ -2871,7 +2871,7 @@ JSONStream_Output(struct iperf_test * test, const char * event_name, cJSON * obj
if (str == NULL)
return -1;
if (test->json_callback != NULL) {
(test->json_callback)(str);
(test->json_callback)(test, str);
} else {
if (pthread_mutex_lock(&(test->print_mutex)) != 0) {
perror("iperf_json_finish: pthread_mutex_lock");
Expand Down Expand Up @@ -5048,7 +5048,7 @@ iperf_json_finish(struct iperf_test *test)
return -1;
}
if (test->json_callback != NULL) {
(test->json_callback)(test->json_output_string);
(test->json_callback)(test, test->json_output_string);
} else {
if (pthread_mutex_lock(&(test->print_mutex)) != 0) {
perror("iperf_json_finish: pthread_mutex_lock");
Expand Down
2 changes: 1 addition & 1 deletion src/iperf_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void iperf_set_test_template( struct iperf_test *ipt, const char *tmp_templat
void iperf_set_test_reverse( struct iperf_test* ipt, int reverse );
void iperf_set_test_json_output( struct iperf_test* ipt, int json_output );
void iperf_set_test_json_stream( struct iperf_test* ipt, int json_stream );
void iperf_set_test_json_callback(struct iperf_test *ipt, void (*callback)());
void iperf_set_test_json_callback(struct iperf_test *ipt, void (*callback)(struct iperf_test *, char *));
int iperf_has_zerocopy( void );
void iperf_set_test_zerocopy( struct iperf_test* ipt, int zerocopy );
void iperf_set_test_get_server_output( struct iperf_test* ipt, int get_server_output );
Expand Down

0 comments on commit 76c60ee

Please sign in to comment.