Source
xxxxxxxxxx
if (NULL == (sequence = (zbx_pp_item_task_sequence_t *)zbx_hashset_search(&queue->sequences, &task->itemid)))
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
ZBX_PTR_VECTOR_IMPL(pp_top_stats_ptr, zbx_pp_top_stats_t *)
/* task sequence registry by itemid */
typedef struct
{
zbx_uint64_t itemid;
zbx_pp_task_t *task;
}
zbx_pp_item_task_sequence_t;
/******************************************************************************
* *
* Purpose: initialize task queue *
* *
* Parameters: queue - [IN] task queue *
* error - [OUT] *
* *
* Return value: SUCCEED - the task queue was initialized successfully *
* FAIL - otherwise *
* *
******************************************************************************/
int pp_task_queue_init(zbx_pp_queue_t *queue, char **error)
{
int err, ret = FAIL;
queue->workers_num = 0;
queue->pending_num = 0;
queue->finished_num = 0;
queue->processing_num = 0;
zbx_list_create(&queue->pending);
zbx_list_create(&queue->immediate);
zbx_list_create(&queue->finished);
zbx_hashset_create(&queue->sequences, 100, ZBX_DEFAULT_UINT64_HASH_FUNC, ZBX_DEFAULT_UINT64_COMPARE_FUNC);
if (0 != (err = pthread_mutex_init(&queue->lock, NULL)))
{
*error = zbx_dsprintf(NULL, "cannot initialize task queue mutex: %s", zbx_strerror(err));
goto out;
}
queue->init_flags |= PP_TASK_QUEUE_INIT_LOCK;
if (0 != (err = pthread_cond_init(&queue->event, NULL)))
{
*error = zbx_dsprintf(NULL, "cannot initialize task queue conditional variable: %s", zbx_strerror(err));
goto out;
}
queue->init_flags |= PP_TASK_QUEUE_INIT_EVENT;
ret = SUCCEED;
out:
if (FAIL == ret)
pp_task_queue_destroy(queue);
return ret;
}
/******************************************************************************
* *
* Purpose: clear task list *
* *
******************************************************************************/
static void pp_task_queue_clear_tasks(zbx_list_t *tasks)
{
zbx_pp_task_t *task = NULL;
while (SUCCEED == zbx_list_pop(tasks, (void **)&task))
pp_task_free(task);