Source
zbx_hashset_create_ext(&manager->rule_index, 0, ZBX_DEFAULT_UINT64_HASH_FUNC, ZBX_DEFAULT_UINT64_COMPARE_FUNC,
/*
** 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/>.
**/
/*
* The LLD queue is organized as a queue (rule_queue binary heap) of LLD rules,
* sorted by their oldest value timestamps. The values are stored in linked lists,
* each rule having its own list of values. Values inside list are not sorted, so
* in the case a LLD rule received a value with past timestamp, it will be processed
* in queuing order, not the value chronological order.
*
* During processing the rule with oldest value is popped from queue and sent
* to a free worker. After processing the rule worker sends done response and
* manager removes the oldest value from rule's value list. If there are no more
* values in the list the rule is removed from the index (rule_index hashset),
* otherwise the rule is enqueued back in LLD queue.
*
*/
typedef struct
{
zbx_ipc_client_t *client;
zbx_lld_rule_t *rule;
}
zbx_lld_worker_t;
ZBX_PTR_VECTOR_DECL(lld_worker_ptr, zbx_lld_worker_t*)
ZBX_PTR_VECTOR_IMPL(lld_worker_ptr, zbx_lld_worker_t*)
typedef struct
{
/* workers vector, created during manager initialization */
zbx_vector_lld_worker_ptr_t workers;
/* free workers */
zbx_queue_ptr_t free_workers;
/* workers indexed by IPC service clients */
zbx_hashset_t workers_client;
/* the next worker index to be assigned to new IPC service clients */
int next_worker_index;