Skip to content

Commit

Permalink
Remove Duplicate Fields From JSON Output When Using Multiple Streams (e…
Browse files Browse the repository at this point in the history
…snet#1492)

* removed duplicate fields from json output when using multiple streams

* updated functionality for udp

* wip

* fix Makefile.in

* wip
  • Loading branch information
manedurphy authored and coolshou committed Jul 13, 2023
1 parent c1a47bd commit 3eb0226
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/iperf_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,21 @@ iperf_tcp_connect(struct iperf_test *test)
}

if (test->json_output) {
cJSON_AddNumberToObject(test->json_start, "sock_bufsize", test->settings->socket_bufsize);
cJSON *sock_bufsize_item = cJSON_GetObjectItem(test->json_start, "sock_bufsize");
if (sock_bufsize_item == NULL) {
cJSON_AddNumberToObject(test->json_start, "sock_bufsize", test->settings->socket_bufsize);
}

cJSON *sndbuf_actual_item = cJSON_GetObjectItem(test->json_start, "sndbuf_actual");
if (sndbuf_actual_item == NULL) {
cJSON_AddNumberToObject(test->json_start, "sndbuf_actual", sndbuf_actual);
}

cJSON *rcvbuf_actual_item = cJSON_GetObjectItem(test->json_start, "rcvbuf_actual");
if (rcvbuf_actual_item == NULL) {
cJSON_AddNumberToObject(test->json_start, "rcvbuf_actual", rcvbuf_actual);
}
}

#if defined(HAVE_FLOWLABEL)
if (test->settings->flowlabel) {
Expand Down
13 changes: 12 additions & 1 deletion src/iperf_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,21 @@ iperf_udp_buffercheck(struct iperf_test *test, int s)
}

if (test->json_output) {
cJSON_AddNumberToObject(test->json_start, "sock_bufsize", test->settings->socket_bufsize);
cJSON *sock_bufsize_item = cJSON_GetObjectItem(test->json_start, "sock_bufsize");
if (sock_bufsize_item == NULL) {
cJSON_AddNumberToObject(test->json_start, "sock_bufsize", test->settings->socket_bufsize);
}

cJSON *sndbuf_actual_item = cJSON_GetObjectItem(test->json_start, "sndbuf_actual");
if (sndbuf_actual_item == NULL) {
cJSON_AddNumberToObject(test->json_start, "sndbuf_actual", sndbuf_actual);
}

cJSON *rcvbuf_actual_item = cJSON_GetObjectItem(test->json_start, "rcvbuf_actual");
if (rcvbuf_actual_item == NULL) {
cJSON_AddNumberToObject(test->json_start, "rcvbuf_actual", rcvbuf_actual);
}
}

return rc;
}
Expand Down

0 comments on commit 3eb0226

Please sign in to comment.