void stats_filter_and_write() { struct jt_msg_stats *msg_stats; pthread_mutex_lock(&unsent_frame_count_mutex); if (g_unsent_frame_count > 0) { stats_filter(g_raw_samples); /* convert from struct iface_stats to struct jt_msg_stats */ msg_stats = malloc(sizeof(struct jt_msg_stats)); assert(msg_stats); iface_stats_to_msg_stats(g_raw_samples, msg_stats); if (0 == jt_srv_send(JT_MSG_STATS_V1, msg_stats)) { g_unsent_frame_count--; } /* cleanup */ jt_messages[JT_MSG_STATS_V1].free(msg_stats); } pthread_mutex_unlock(&unsent_frame_count_mutex); }
inline static int message_producer(struct mq_stats_msg *m, void *data) { int *decimation_factor = (int *)data; return stats_filter(sample_list, m, *decimation_factor); }