MCPcopy Create free account
hub / github.com/Netis/cloud-probe / task_manager_collect_stats_summary_command

Function task_manager_collect_stats_summary_command

cpworker/src/task.c:818–865  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

816}
817
818int task_manager_collect_stats_summary_command(cJSON *cmd_msg, cJSON *server_msg, void *data)
819{
820 task_manager_t *this = &task_mgr;
821
822 pthread_mutex_lock(&this->stats_lock);
823 task_stats_summary_snapshot_t stats = this->stats_summary_snapshot;
824 pthread_mutex_unlock(&this->stats_lock);
825
826 cJSON *time = cJSON_CreateObject();
827 if (!time)
828 goto error;
829 cJSON_AddItemToObject(server_msg, "time", time);
830
831 cJSON *tv_sec = cJSON_CreateNumber(stats.tm.tv_sec);
832 if (!tv_sec)
833 goto error;
834 cJSON_AddItemToObject(time, "sec", tv_sec);
835
836 cJSON *tv_nsec = cJSON_CreateNumber(stats.tm.tv_nsec);
837 if (!tv_nsec)
838 goto error;
839 cJSON_AddItemToObject(time, "nsec", tv_nsec);
840
841 cJSON *capture = cJSON_CreateObject();
842 if (!capture)
843 goto error;
844 cJSON_AddItemToObject(server_msg, "capture", capture);
845 if (capture_stats_json_dump(&stats.capture, capture) != 0)
846 goto error;
847
848 cJSON *output = cJSON_CreateObject();
849 if (!output)
850 goto error;
851 cJSON_AddItemToObject(server_msg, "output", output);
852 if (output_stats_json_dump(&stats.output, output) != 0)
853 goto error;
854
855 cJSON *pipeline_buffer = cJSON_CreateObject();
856 if (!pipeline_buffer)
857 goto error;
858 cJSON_AddItemToObject(server_msg, "pipeline_buffer", pipeline_buffer);
859 if (pipeline_buffer_stats_json_dump(&stats.pipeline_buffer, pipeline_buffer) != 0)
860 goto error;
861
862 return 0;
863error:
864 return -1;
865}
866
867/*
868 * 硬约束:

Callers

nothing calls this directly

Calls 6

cJSON_CreateObjectFunction · 0.85
cJSON_AddItemToObjectFunction · 0.85
cJSON_CreateNumberFunction · 0.85
capture_stats_json_dumpFunction · 0.85
output_stats_json_dumpFunction · 0.85

Tested by

no test coverage detected