MCPcopy Create free account
hub / github.com/esnet/iperf / JSONStream_Output

Function JSONStream_Output

src/iperf_api.c:3085–3111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3083 */
3084
3085static int
3086JSONStream_Output(struct iperf_test * test, const char * event_name, cJSON * obj)
3087{
3088 cJSON *event = cJSON_CreateObject();
3089 if (!event)
3090 return -1;
3091 cJSON_AddStringToObject(event, "event", event_name);
3092 cJSON_AddItemReferenceToObject(event, "data", obj);
3093 char *str = cJSON_PrintUnformatted(event);
3094 if (str == NULL)
3095 return -1;
3096 if (test->json_callback != NULL) {
3097 (test->json_callback)(test, str);
3098 } else {
3099 if (pthread_mutex_lock(&(test->print_mutex)) != 0) {
3100 perror("iperf_json_finish: pthread_mutex_lock");
3101 }
3102 fprintf(test->outfile, "%s\n", str);
3103 if (pthread_mutex_unlock(&(test->print_mutex)) != 0) {
3104 perror("iperf_json_finish: pthread_mutex_unlock");
3105 }
3106 }
3107 iflush(test);
3108 cJSON_free(str);
3109 cJSON_Delete(event);
3110 return 0;
3111}
3112
3113/*************************************************************/
3114/**

Callers 3

iperf_on_test_startFunction · 0.85
iperf_print_intermediateFunction · 0.85
iperf_json_finishFunction · 0.85

Calls 7

cJSON_CreateObjectFunction · 0.85
cJSON_AddStringToObjectFunction · 0.85
cJSON_PrintUnformattedFunction · 0.85
iflushFunction · 0.85
cJSON_freeFunction · 0.85
cJSON_DeleteFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…