zabbix-agent2/src/zabbix_server/alerter/alert_manager.c
/******************************************************************************
 *                                                                            *
 * Function: am_flush_results                                                 *
 *                                                                            *
 * Purpose: returns alert sending results                                     *
 *                                                                            *
 ******************************************************************************/
am_flush_results

Purpose: returns alert sending results
am_flush_results Purpose : returns alert sending results
static void	am_flush_results(zbx_am_t *manager, zbx_ipc_client_t *client)
{
	zbx_vector_ptr_t	results;
	zbx_hashset_iter_t	iter;
	zbx_am_result_t		*result;
	zbx_uint32_t		data_len;
	unsigned char		*data;
	zabbix_log(LOG_LEVEL_DEBUG, "In %s() results:%d", __func__, manager->results.num_data);
	if (0 == manager->results.num_data)
	{
		int		results_num = 0;
		unsigned char	buf[sizeof(results_num)];
		(void)zbx_serialize_value(buf, results_num);
		zbx_ipc_client_send(client, ZBX_IPC_ALERTER_RESULTS, buf, sizeof(results_num));
		goto out;
	}
	zbx_vector_ptr_create(&results);
	zbx_hashset_iter_reset(&manager->results, &iter);
	while (NULL != (result = (zbx_am_result_t *)zbx_hashset_iter_next(&iter)))
		zbx_vector_ptr_append(&results, result);
	zbx_vector_ptr_sort(&results, ZBX_DEFAULT_UINT64_PTR_COMPARE_FUNC);
	data_len = zbx_alerter_serialize_results(&data, (zbx_am_result_t **)results.values, results.values_num);
	zbx_ipc_client_send(client, ZBX_IPC_ALERTER_RESULTS, data, data_len);
	zbx_free(data);
	zbx_hashset_iter_reset(&manager->results, &iter);
	while (NULL != (result = (zbx_am_result_t *)zbx_hashset_iter_next(&iter)))
	{
		zbx_free(result->value);
		zbx_free(result->error);
	}
	zbx_hashset_clear(&manager->results);
	zbx_vector_ptr_destroy(&results);
out:
	zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __func__);
}
static void am_flush_results ( zbx_am_t * manager , zbx_ipc_client_t * client ) { zbx_vector_ptr_t results ; zbx_hashset_iter_t iter ; zbx_am_result_t * result ; zbx_uint32_t data_len ; unsigned char * data ; zabbix_log ( LOG_LEVEL_DEBUG , " " , __func__ , manager -> results . num_data ) ; if ( 0 == manager -> results . num_data ) { int results_num = 0 ; unsigned char buf [ sizeof ( results_num ) ] ; ( void ) zbx_serialize_value ( buf , results_num ) ; zbx_ipc_client_send ( client , ZBX_IPC_ALERTER_RESULTS , buf , sizeof ( results_num ) ) ; goto out ; } zbx_vector_ptr_create ( & results ) ; zbx_hashset_iter_reset ( & manager -> results , & iter ) ; while ( NULL != ( result = ( zbx_am_result_t * ) zbx_hashset_iter_next ( & iter ) ) ) zbx_vector_ptr_append ( & results , result ) ; zbx_vector_ptr_sort ( & results , ZBX_DEFAULT_UINT64_PTR_COMPARE_FUNC ) ; data_len = zbx_alerter_serialize_results ( & data , ( zbx_am_result_t * * ) results . values , results . values_num ) ; zbx_ipc_client_send ( client , ZBX_IPC_ALERTER_RESULTS , data , data_len ) ; zbx_free ( data ) ; zbx_hashset_iter_reset ( & manager -> results , & iter ) ; while ( NULL != ( result = ( zbx_am_result_t * ) zbx_hashset_iter_next ( & iter ) ) ) { zbx_free ( result -> value ) ; zbx_free ( result -> error ) ; } zbx_hashset_clear ( & manager -> results ) ; zbx_vector_ptr_destroy ( & results ) ; out : zabbix_log ( LOG_LEVEL_DEBUG , " " , __func__ ) ; }
Function: am_flush_results                                                 
                                                                            
 Purpose: returns alert sending results
Function : am_flush_results Purpose : returns alert sending results