Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJurijs Klopovskis <jurijs.klopovskis@zabbix.com>2022-04-06 09:43:16 +0300
committerJurijs Klopovskis <jurijs.klopovskis@zabbix.com>2022-04-06 09:43:16 +0300
commit060d5976b4416e9aa073d7018c6af54230e5b915 (patch)
tree52ee7805123e3358e20f5ac418f4ab9747a3b349 /src
parentc3f14ad6bf2d0715ac8fd83d596d202651228acf (diff)
parente86c003ad31c2eaf66a46d90c70240225b661533 (diff)
.......... [ZBX-20398] merged latest changes from master
Diffstat (limited to 'src')
-rw-r--r--src/libs/Makefile.am6
-rw-r--r--src/libs/zbxalgo/Makefile.am2
-rw-r--r--src/libs/zbxalgo/algodefs.c193
-rw-r--r--src/libs/zbxalgo/algodefs.h25
-rw-r--r--src/libs/zbxalgo/binaryheap.c4
-rw-r--r--src/libs/zbxalgo/evaluate.c13
-rw-r--r--src/libs/zbxalgo/hashmap.c11
-rw-r--r--src/libs/zbxalgo/hashset.c10
-rw-r--r--src/libs/zbxalgo/int128.c22
-rw-r--r--src/libs/zbxalgo/linked_list.c3
-rw-r--r--src/libs/zbxalgo/prediction.c4
-rw-r--r--src/libs/zbxalgo/queue.c3
-rw-r--r--src/libs/zbxalgo/serialize.c3
-rw-r--r--src/libs/zbxalgo/vector.c5
-rw-r--r--src/libs/zbxalgo/vectorimpl.h296
-rw-r--r--src/libs/zbxcommon/variant.c5
-rw-r--r--src/libs/zbxcomms/Makefile.am1
-rw-r--r--src/libs/zbxcomms/comms.c1
-rw-r--r--src/libs/zbxcomms/comms.h43
-rw-r--r--src/libs/zbxcomms/telnet.c30
-rw-r--r--src/libs/zbxcommshigh/commshigh.c2
-rw-r--r--src/libs/zbxdbcache/dbcache.c83
-rw-r--r--src/libs/zbxdbcache/dbconfig.c238
-rw-r--r--src/libs/zbxdbcache/valuecache.c40
-rw-r--r--src/libs/zbxdbcache/valuecache.h4
-rw-r--r--src/libs/zbxdbhigh/graph_linking.c1
-rw-r--r--src/libs/zbxdbhigh/host.c1
-rw-r--r--src/libs/zbxdbhigh/tag.c1
-rw-r--r--src/libs/zbxdbhigh/template_item.c1
-rw-r--r--src/libs/zbxdbhigh/trigger_dep_linking.c1
-rw-r--r--src/libs/zbxdbhigh/trigger_linking.c1
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade.c3
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_2010.c4
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_2020.c1
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_2030.c4
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_2040.c3
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_2050.c4
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_3000.c1
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_3010.c4
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_3020.c4
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_3030.c4
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_3040.c3
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_3050.c4
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_4000.c4
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_4010.c4
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_4020.c1
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_4030.c4
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_4040.c1
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_4050.c5
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_5000.c1
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_5010.c5
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_5020.c1
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_5030.c7
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_5040.c1
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_5050.c5
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_macros.c2
-rw-r--r--src/libs/zbxdbupgrade/dbupgrade_macros.h1
-rw-r--r--src/libs/zbxdiag/diag.c10
-rw-r--r--src/libs/zbxdiag/diag.h4
-rw-r--r--src/libs/zbxdiag/diag_server.c2
-rw-r--r--src/libs/zbxeval/calc.c1
-rw-r--r--src/libs/zbxeval/parse.c2
-rw-r--r--src/libs/zbxhistory/history.c1
-rw-r--r--src/libs/zbxjson/jsonpath.c1
-rw-r--r--src/libs/zbxnix/Makefile.am1
-rw-r--r--src/libs/zbxnix/control.c3
-rw-r--r--src/libs/zbxnix/control.h4
-rw-r--r--src/libs/zbxnix/coredump.c3
-rw-r--r--src/libs/zbxnix/daemon.c17
-rw-r--r--src/libs/zbxnix/dshm.c3
-rw-r--r--src/libs/zbxnix/fatal.h4
-rw-r--r--src/libs/zbxnix/ipc.c2
-rw-r--r--src/libs/zbxnix/pid.c2
-rw-r--r--src/libs/zbxnix/pid.h34
-rw-r--r--src/libs/zbxnix/sighandler.c5
-rw-r--r--src/libs/zbxrtc/rtc_service.c8
-rw-r--r--src/libs/zbxself/selfmon.c2
-rw-r--r--src/libs/zbxserver/anomalystl.c1
-rw-r--r--src/libs/zbxserver/evalfunc.c18
-rw-r--r--src/libs/zbxserver/expression.c3
-rw-r--r--src/libs/zbxservice/service.c1
-rw-r--r--src/libs/zbxshmem/Makefile.am (renamed from src/libs/zbxmemory/Makefile.am)4
-rw-r--r--src/libs/zbxshmem/memalloc.c (renamed from src/libs/zbxmemory/memalloc.c)228
-rw-r--r--src/libs/zbxsysinfo/simple/simple.c3
-rw-r--r--src/libs/zbxsysinfo/sysinfo.c2
-rw-r--r--src/libs/zbxsysinfo/win32/wmi.cpp1
-rw-r--r--src/libs/zbxtrends/cache.c20
-rw-r--r--src/libs/zbxxml/xml.c2
-rw-r--r--src/zabbix_agent/active.c2
-rw-r--r--src/zabbix_agent/listener.c2
-rw-r--r--src/zabbix_agent/logfiles/persistent_state.c1
-rw-r--r--src/zabbix_agent/procstat.c2
-rw-r--r--src/zabbix_agent/stats.c2
-rw-r--r--src/zabbix_agent/stats.h2
-rw-r--r--src/zabbix_agent/zabbix_agentd.c8
-rw-r--r--src/zabbix_proxy/Makefile.am2
-rw-r--r--src/zabbix_proxy/datasender/datasender.c2
-rw-r--r--src/zabbix_proxy/heart/heart.c2
-rw-r--r--src/zabbix_proxy/housekeeper/housekeeper.c2
-rw-r--r--src/zabbix_proxy/proxy.c4
-rw-r--r--src/zabbix_proxy/proxyconfig/proxyconfig.c2
-rw-r--r--src/zabbix_proxy/taskmanager/taskmanager.c2
-rw-r--r--src/zabbix_server/Makefile.am2
-rw-r--r--src/zabbix_server/actions.c2
-rw-r--r--src/zabbix_server/alerter/alert_manager.c8
-rw-r--r--src/zabbix_server/alerter/alert_syncer.c3
-rw-r--r--src/zabbix_server/alerter/alerter.c2
-rw-r--r--src/zabbix_server/availability/avail_manager.c4
-rw-r--r--src/zabbix_server/dbconfig/dbconfig.c2
-rw-r--r--src/zabbix_server/dbsyncer/dbsyncer.c3
-rw-r--r--src/zabbix_server/discoverer/discoverer.c2
-rw-r--r--src/zabbix_server/escalator/escalator.c3
-rw-r--r--src/zabbix_server/events.c2
-rw-r--r--src/zabbix_server/ha/ha_manager.c1
-rw-r--r--src/zabbix_server/housekeeper/housekeeper.c2
-rw-r--r--src/zabbix_server/housekeeper/trigger_housekeeper.c2
-rw-r--r--src/zabbix_server/httppoller/httppoller.c2
-rw-r--r--src/zabbix_server/httppoller/httptest.c2
-rw-r--r--src/zabbix_server/ipmi/ipmi_manager.c13
-rw-r--r--src/zabbix_server/ipmi/ipmi_poller.c2
-rw-r--r--src/zabbix_server/lld/lld.c4
-rw-r--r--src/zabbix_server/lld/lld_manager.c2
-rw-r--r--src/zabbix_server/lld/lld_worker.c2
-rw-r--r--src/zabbix_server/pinger/pinger.c2
-rw-r--r--src/zabbix_server/poller/checks_snmp.c3
-rw-r--r--src/zabbix_server/poller/checks_telnet.c7
-rw-r--r--src/zabbix_server/poller/poller.c2
-rw-r--r--src/zabbix_server/preprocessor/preproc_cache.c1
-rw-r--r--src/zabbix_server/preprocessor/preproc_manager.c5
-rw-r--r--src/zabbix_server/preprocessor/preproc_worker.c2
-rw-r--r--src/zabbix_server/preprocessor/preprocessing.c1
-rw-r--r--src/zabbix_server/proxypoller/proxypoller.c2
-rw-r--r--src/zabbix_server/reporter/report_manager.c56
-rw-r--r--src/zabbix_server/reporter/report_writer.c2
-rw-r--r--src/zabbix_server/selfmon/selfmon.c2
-rw-r--r--src/zabbix_server/server.c4
-rw-r--r--src/zabbix_server/service/service_actions.c2
-rw-r--r--src/zabbix_server/service/service_manager.c2
-rw-r--r--src/zabbix_server/snmptrapper/snmptrapper.c2
-rw-r--r--src/zabbix_server/taskmanager/taskmanager.c2
-rw-r--r--src/zabbix_server/timer/timer.c2
-rw-r--r--src/zabbix_server/trapper/proxydata.c2
-rw-r--r--src/zabbix_server/trapper/trapper.c2
-rw-r--r--src/zabbix_server/vmware/vmware.c117
144 files changed, 743 insertions, 1103 deletions
diff --git a/src/libs/Makefile.am b/src/libs/Makefile.am
index e4232113685..67598051664 100644
--- a/src/libs/Makefile.am
+++ b/src/libs/Makefile.am
@@ -5,7 +5,7 @@ DIST_SUBDIRS = \
zbxdbhigh \
zbxdb \
zbxdbupgrade \
- zbxmemory \
+ zbxshmem \
zbxalgo \
zbxmedia \
zbxcrypto \
@@ -53,7 +53,7 @@ SERVER_SUBDIRS = \
zbxdbcache \
zbxdbhigh \
zbxhttp \
- zbxmemory \
+ zbxshmem \
zbxserver \
zbxicmpping \
zbxmedia \
@@ -84,7 +84,7 @@ PROXY_SUBDIRS = \
zbxdbcache \
zbxdbhigh \
zbxhttp \
- zbxmemory \
+ zbxshmem \
zbxserver \
zbxicmpping \
zbxself \
diff --git a/src/libs/zbxalgo/Makefile.am b/src/libs/zbxalgo/Makefile.am
index a57a7d9a16b..0ff55ad1565 100644
--- a/src/libs/zbxalgo/Makefile.am
+++ b/src/libs/zbxalgo/Makefile.am
@@ -11,6 +11,7 @@ endif
endif
libzbxalgo_a_SOURCES = \
+ algodefs.h \
algodefs.c \
binaryheap.c \
$(EVALUATE_C) \
@@ -21,5 +22,4 @@ libzbxalgo_a_SOURCES = \
prediction.c \
queue.c \
vector.c \
- vectorimpl.h \
serialize.c
diff --git a/src/libs/zbxalgo/algodefs.c b/src/libs/zbxalgo/algodefs.c
index b6f2afd4e17..96fd9226ff0 100644
--- a/src/libs/zbxalgo/algodefs.c
+++ b/src/libs/zbxalgo/algodefs.c
@@ -17,80 +17,12 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
-
#include "zbxalgo.h"
+#include "algodefs.h"
-typedef unsigned char uchar;
-
-/*
- * Bob Jenkins hash function (see http://burtleburtle.net/bob/hash/evahash.html)
- */
-zbx_hash_t zbx_hash_lookup2(const void *data, size_t len, zbx_hash_t seed)
-{
- const uchar *p = (const uchar *)data;
-
- zbx_hash_t a, b, c;
-
-#define mix(a, b, c) \
-{ \
- a = a - b; a = a - c; a = a ^ (c >> 13); \
- b = b - c; b = b - a; b = b ^ (a << 8); \
- c = c - a; c = c - b; c = c ^ (b >> 13); \
- a = a - b; a = a - c; a = a ^ (c >> 12); \
- b = b - c; b = b - a; b = b ^ (a << 16); \
- c = c - a; c = c - b; c = c ^ (b >> 5); \
- a = a - b; a = a - c; a = a ^ (c >> 3); \
- b = b - c; b = b - a; b = b ^ (a << 10); \
- c = c - a; c = c - b; c = c ^ (b >> 15); \
-}
-
- a = b = 0x9e3779b9u;
- c = seed;
-
- while (len >= 12)
- {
- a = a + (p[0] + ((zbx_hash_t)p[1] << 8) + ((zbx_hash_t)p[2] << 16) + ((zbx_hash_t)p[3] << 24));
- b = b + (p[4] + ((zbx_hash_t)p[5] << 8) + ((zbx_hash_t)p[6] << 16) + ((zbx_hash_t)p[7] << 24));
- c = c + (p[8] + ((zbx_hash_t)p[9] << 8) + ((zbx_hash_t)p[10] << 16) + ((zbx_hash_t)p[11] << 24));
-
- mix(a, b, c);
-
- p += 12;
- len -= 12;
- }
-
- c = c + (zbx_hash_t)len;
-
- switch (len)
- {
- case 11: c = c + ((zbx_hash_t)p[10] << 24);
- ZBX_FALLTHROUGH;
- case 10: c = c + ((zbx_hash_t)p[9] << 16);
- ZBX_FALLTHROUGH;
- case 9: c = c + ((zbx_hash_t)p[8] << 8);
- ZBX_FALLTHROUGH;
- case 8: b = b + ((zbx_hash_t)p[7] << 24);
- ZBX_FALLTHROUGH;
- case 7: b = b + ((zbx_hash_t)p[6] << 16);
- ZBX_FALLTHROUGH;
- case 6: b = b + ((zbx_hash_t)p[5] << 8);
- ZBX_FALLTHROUGH;
- case 5: b = b + p[4];
- ZBX_FALLTHROUGH;
- case 4: a = a + ((zbx_hash_t)p[3] << 24);
- ZBX_FALLTHROUGH;
- case 3: a = a + ((zbx_hash_t)p[2] << 16);
- ZBX_FALLTHROUGH;
- case 2: a = a + ((zbx_hash_t)p[1] << 8);
- ZBX_FALLTHROUGH;
- case 1: a = a + p[0];
- }
-
- mix(a, b, c);
+#include "common.h"
- return c;
-}
+typedef unsigned char uchar;
/*
* modified FNV hash function (see http://www.isthe.com/chongo/tech/comp/fnv/)
@@ -118,123 +50,6 @@ zbx_hash_t zbx_hash_modfnv(const void *data, size_t len, zbx_hash_t seed)
}
/*
- * Murmur (see http://sites.google.com/site/murmurhash/)
- */
-zbx_hash_t zbx_hash_murmur2(const void *data, size_t len, zbx_hash_t seed)
-{
- const uchar *p = (const uchar *)data;
-
- zbx_hash_t hash;
-
- const zbx_hash_t m = 0x5bd1e995u;
- const zbx_hash_t r = 24;
-
- hash = seed ^ (zbx_hash_t)len;
-
- while (len >= 4)
- {
- zbx_hash_t k;
-
- k = p[0];
- k |= p[1] << 8;
- k |= p[2] << 16;
- k |= p[3] << 24;
-
- k *= m;
- k ^= k >> r;
- k *= m;
-
- hash *= m;
- hash ^= k;
-
- p += 4;
- len -= 4;
- }
-
- switch (len)
- {
- case 3: hash ^= p[2] << 16;
- ZBX_FALLTHROUGH;
- case 2: hash ^= p[1] << 8;
- ZBX_FALLTHROUGH;
- case 1: hash ^= p[0];
- hash *= m;
- }
-
- hash ^= hash >> 13;
- hash *= m;
- hash ^= hash >> 15;
-
- return hash;
-}
-
-/*
- * sdbm (see http://www.cse.yorku.ca/~oz/hash.html)
- */
-zbx_hash_t zbx_hash_sdbm(const void *data, size_t len, zbx_hash_t seed)
-{
- const uchar *p = (const uchar *)data;
-
- zbx_hash_t hash = seed;
-
-#if 1
-
- while (len-- >= 1)
- {
- /* hash = *(p++) + hash * 65599; */
-
- hash = *(p++) + (hash << 6) + (hash << 16) - hash;
- }
-
-#else /* Duff's device */
-
-#define HASH_STEP len--; \
- hash = *(p++) + (hash << 6) + (hash << 16) - hash
-
- switch (len & 7)
- {
- do
- {
- HASH_STEP;
- case 7: HASH_STEP;
- case 6: HASH_STEP;
- case 5: HASH_STEP;
- case 4: HASH_STEP;
- case 3: HASH_STEP;
- case 2: HASH_STEP;
- case 1: HASH_STEP;
- case 0: ;
- }
- while (len >= 8);
- }
-
-#endif
-
- return hash;
-}
-
-/*
- * djb2 (see http://www.cse.yorku.ca/~oz/hash.html)
- */
-zbx_hash_t zbx_hash_djb2(const void *data, size_t len, zbx_hash_t seed)
-{
- const uchar *p = (const uchar *)data;
-
- zbx_hash_t hash;
-
- hash = 5381u ^ seed;
-
- while (len-- >= 1)
- {
- /* hash = hash * 33 + *(p++); */
-
- hash = ((hash << 5) + hash) + *(p++);
- }
-
- return hash;
-}
-
-/*
* see http://xoshiro.di.unimi.it/splitmix64.c
*/
zbx_hash_t zbx_hash_splittable64(const void *data)
@@ -364,7 +179,7 @@ void zbx_default_mem_free_func(void *ptr)
/* numeric functions */
-int is_prime(int n)
+static int is_prime(int n)
{
int i;
diff --git a/src/libs/zbxalgo/algodefs.h b/src/libs/zbxalgo/algodefs.h
new file mode 100644
index 00000000000..36355330fb4
--- /dev/null
+++ b/src/libs/zbxalgo/algodefs.h
@@ -0,0 +1,25 @@
+/*
+** Zabbix
+** Copyright (C) 2001-2022 Zabbix SIA
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** 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 General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+**/
+
+#ifndef ZABBIX_ALGO_H
+#define ZABBIX_ALGO_H
+
+int next_prime(int n);
+
+#endif /* ZABBIX_ALGO_H */
diff --git a/src/libs/zbxalgo/binaryheap.c b/src/libs/zbxalgo/binaryheap.c
index 8768c24630f..eabac8786eb 100644
--- a/src/libs/zbxalgo/binaryheap.c
+++ b/src/libs/zbxalgo/binaryheap.c
@@ -17,11 +17,11 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
+#include "zbxalgo.h"
+
#include "common.h"
#include "log.h"
-#include "zbxalgo.h"
-
static void swap(zbx_binary_heap_t *heap, int index_1, int index_2);
static void __binary_heap_ensure_free_space(zbx_binary_heap_t *heap);
diff --git a/src/libs/zbxalgo/evaluate.c b/src/libs/zbxalgo/evaluate.c
index b324a818407..c73888d4f0d 100644
--- a/src/libs/zbxalgo/evaluate.c
+++ b/src/libs/zbxalgo/evaluate.c
@@ -17,8 +17,9 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
#include "zbxalgo.h"
+
+#include "common.h"
#include "zbxvariant.h"
#include "log.h"
@@ -187,7 +188,7 @@ static void variant_convert_to_double(zbx_variant_t *var)
{
if (ZBX_VARIANT_STR == var->type)
{
- double var_double_value = evaluate_string_to_double(var->data.str);
+ double var_double_value = zbx_evaluate_string_to_double(var->data.str);
if (ZBX_INFINITY == var_double_value)
{
zbx_snprintf(buffer, max_buffer_len, "Cannot evaluate expression:"
@@ -219,7 +220,7 @@ static double variant_get_double(const zbx_variant_t *var)
case ZBX_VARIANT_DBL:
return var->data.dbl;
case ZBX_VARIANT_STR:
- return evaluate_string_to_double(var->data.str);
+ return zbx_evaluate_string_to_double(var->data.str);
default:
THIS_SHOULD_NEVER_HAPPEN;
return ZBX_INFINITY;
@@ -953,7 +954,7 @@ static zbx_variant_t evaluate_term1(int *unknown_idx)
* Purpose: evaluate an expression like "(26.416>10) or (0=1)" *
* *
******************************************************************************/
-int evaluate(double *value, const char *expression, char *error, size_t max_error_len,
+int zbx_evaluate(double *value, const char *expression, char *error, size_t max_error_len,
zbx_vector_ptr_t *unknown_msgs)
{
int unknown_idx = -13; /* index of message in 'unknown_msgs' vector, set to invalid value */
@@ -1052,7 +1053,7 @@ int evaluate(double *value, const char *expression, char *error, size_t max_erro
* FAIL - expression evaluation failed *
* *
******************************************************************************/
-int evaluate_unknown(const char *expression, double *value, char *error, size_t max_error_len)
+int zbx_evaluate_unknown(const char *expression, double *value, char *error, size_t max_error_len)
{
const char *__function_name = "evaluate_with_unknown";
zbx_variant_t res;
@@ -1096,7 +1097,7 @@ int evaluate_unknown(const char *expression, double *value, char *error, size_t
* Return value: - the resulting double *
* *
******************************************************************************/
-double evaluate_string_to_double(const char *in)
+double zbx_evaluate_string_to_double(const char *in)
{
int len;
double result_double_value;
diff --git a/src/libs/zbxalgo/hashmap.c b/src/libs/zbxalgo/hashmap.c
index 1c95629c146..8fb4ea74735 100644
--- a/src/libs/zbxalgo/hashmap.c
+++ b/src/libs/zbxalgo/hashmap.c
@@ -17,9 +17,10 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
-
#include "zbxalgo.h"
+#include "algodefs.h"
+
+#include "common.h"
static void __hashmap_ensure_free_entry(zbx_hashmap_t *hm, ZBX_HASHMAP_SLOT_T *slot);
@@ -38,12 +39,14 @@ static void __hashmap_ensure_free_entry(zbx_hashmap_t *hm, ZBX_HASHMAP_SLOT_T *s
{
slot->entries_num = 0;
slot->entries_alloc = 6;
- slot->entries = (ZBX_HASHMAP_ENTRY_T *)hm->mem_malloc_func(NULL, slot->entries_alloc * sizeof(ZBX_HASHMAP_ENTRY_T));
+ slot->entries = (ZBX_HASHMAP_ENTRY_T *)hm->mem_malloc_func(NULL, slot->entries_alloc *
+ sizeof(ZBX_HASHMAP_ENTRY_T));
}
else if (slot->entries_num == slot->entries_alloc)
{
slot->entries_alloc = slot->entries_alloc * ARRAY_GROWTH_FACTOR;
- slot->entries = (ZBX_HASHMAP_ENTRY_T *)hm->mem_realloc_func(slot->entries, slot->entries_alloc * sizeof(ZBX_HASHMAP_ENTRY_T));
+ slot->entries = (ZBX_HASHMAP_ENTRY_T *)hm->mem_realloc_func(slot->entries, slot->entries_alloc *
+ sizeof(ZBX_HASHMAP_ENTRY_T));
}
}
diff --git a/src/libs/zbxalgo/hashset.c b/src/libs/zbxalgo/hashset.c
index 01a0deab89c..a75fa0f8bf1 100644
--- a/src/libs/zbxalgo/hashset.c
+++ b/src/libs/zbxalgo/hashset.c
@@ -17,11 +17,12 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
+#include "zbxalgo.h"
+#include "algodefs.h"
+
#include "common.h"
#include "log.h"
-#include "zbxalgo.h"
-
static void __hashset_free_entry(zbx_hashset_t *hs, ZBX_HASHSET_ENTRY_T *entry);
#define CRIT_LOAD_FACTOR 4/5
@@ -47,8 +48,11 @@ static int zbx_hashset_init_slots(zbx_hashset_t *hs, size_t init_size)
{
hs->num_slots = next_prime(init_size);
- if (NULL == (hs->slots = (ZBX_HASHSET_ENTRY_T **)hs->mem_malloc_func(NULL, hs->num_slots * sizeof(ZBX_HASHSET_ENTRY_T *))))
+ if (NULL == (hs->slots = (ZBX_HASHSET_ENTRY_T **)hs->mem_malloc_func(NULL, hs->num_slots *
+ sizeof(ZBX_HASHSET_ENTRY_T *))))
+ {
return FAIL;
+ }
memset(hs->slots, 0, hs->num_slots * sizeof(ZBX_HASHSET_ENTRY_T *));
}
diff --git a/src/libs/zbxalgo/int128.c b/src/libs/zbxalgo/int128.c
index 9663fce24d0..d4d43974e3c 100644
--- a/src/libs/zbxalgo/int128.c
+++ b/src/libs/zbxalgo/int128.c
@@ -17,9 +17,10 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "zbxtypes.h"
#include "zbxalgo.h"
+#include "zbxtypes.h"
+
#define UINT64_BIT_COUNT (sizeof(zbx_uint64_t) << 3)
#define UINT32_BIT_COUNT (UINT64_BIT_COUNT >> 1)
#define UINT32_BIT_MASK (~((~__UINT64_C(0)) << UINT32_BIT_COUNT))
@@ -115,6 +116,9 @@ static int ucmp128_128(const zbx_uint128_t *value1, const zbx_uint128_t *value2)
return value1->lo < value2->lo ? -1 : 1;
}
+/* 128 bit unsigned integer handling */
+#define uset128(base, hi64, lo64) (base)->hi = hi64; (base)->lo = lo64
+
/******************************************************************************
* *
* Purpose: Multiplication of 64 bit unsigned integer with 32 bit unsigned *
@@ -126,7 +130,7 @@ static int ucmp128_128(const zbx_uint128_t *value1, const zbx_uint128_t *value2)
* shift - [IN] the number of bits to shift the result by before *
* adding it to the base value. *
* *
- * Comments: This is a helper function for umul64_64 implementation. *
+ * Comments: This is a helper function for zbx_umul64_64 implementation. *
* *
******************************************************************************/
static void umul64_32_shift(zbx_uint128_t *base, zbx_uint64_t value, zbx_uint64_t factor, int shift)
@@ -135,11 +139,11 @@ static void umul64_32_shift(zbx_uint128_t *base, zbx_uint64_t value, zbx_uint64_
uset128(&buffer, 0, (value & UINT32_BIT_MASK) * factor);
ushiftl128(&buffer, shift);
- uinc128_128(base, &buffer);
+ zbx_uinc128_128(base, &buffer);
uset128(&buffer, 0, (value >> UINT32_BIT_COUNT) * factor);
ushiftl128(&buffer, UINT32_BIT_COUNT + shift);
- uinc128_128(base, &buffer);
+ zbx_uinc128_128(base, &buffer);
}
/******************************************************************************
@@ -151,7 +155,7 @@ static void umul64_32_shift(zbx_uint128_t *base, zbx_uint64_t value, zbx_uint64_
* value - [IN] the value to increment by. *
* *
******************************************************************************/
-void uinc128_64(zbx_uint128_t *base, zbx_uint64_t value)
+void zbx_uinc128_64(zbx_uint128_t *base, zbx_uint64_t value)
{
zbx_uint64_t low = base->lo;
@@ -170,7 +174,7 @@ void uinc128_64(zbx_uint128_t *base, zbx_uint64_t value)
* value - [IN] the value to increment by. *
* *
******************************************************************************/
-void uinc128_128(zbx_uint128_t *base, const zbx_uint128_t *value)
+void zbx_uinc128_128(zbx_uint128_t *base, const zbx_uint128_t *value)
{
zbx_uint64_t low = base->lo;
@@ -190,7 +194,7 @@ void uinc128_128(zbx_uint128_t *base, const zbx_uint128_t *value)
* factor - [IN] the factor to multiply by. *
* *
******************************************************************************/
-void umul64_64(zbx_uint128_t *result, zbx_uint64_t value, zbx_uint64_t factor)
+void zbx_umul64_64(zbx_uint128_t *result, zbx_uint64_t value, zbx_uint64_t factor)
{
uset128(result, 0, 0);
/* multiply the value with lower double word of factor and add the result */
@@ -209,7 +213,7 @@ void umul64_64(zbx_uint128_t *result, zbx_uint64_t value, zbx_uint64_t factor)
* value - [IN] the divisor. *
* *
******************************************************************************/
-void udiv128_64(zbx_uint128_t *result, const zbx_uint128_t *dividend, zbx_uint64_t value)
+void zbx_udiv128_64(zbx_uint128_t *result, const zbx_uint128_t *dividend, zbx_uint64_t value)
{
zbx_uint128_t reminder, divisor;
zbx_uint64_t result_mask = __UINT64_C(1) << (UINT64_BIT_COUNT - 1);
@@ -256,3 +260,5 @@ void udiv128_64(zbx_uint128_t *result, const zbx_uint128_t *dividend, zbx_uint64
/* reminder is less than 64 bits, proceed with 64bit division */
result->lo |= reminder.lo / value;
}
+
+#undef uset128
diff --git a/src/libs/zbxalgo/linked_list.c b/src/libs/zbxalgo/linked_list.c
index b75bc1b8132..8964958edcb 100644
--- a/src/libs/zbxalgo/linked_list.c
+++ b/src/libs/zbxalgo/linked_list.c
@@ -17,9 +17,10 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
#include "zbxalgo.h"
+#include "common.h"
+
/******************************************************************************
* *
* Purpose: create singly linked list (with custom memory functions) *
diff --git a/src/libs/zbxalgo/prediction.c b/src/libs/zbxalgo/prediction.c
index efea3e720c8..4efe4200fba 100644
--- a/src/libs/zbxalgo/prediction.c
+++ b/src/libs/zbxalgo/prediction.c
@@ -17,11 +17,11 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
+#include "zbxalgo.h"
+
#include "common.h"
#include "log.h"
-#include "zbxalgo.h"
-
#define DB_INFINITY (1e12 - 1e-4)
#define ZBX_MATH_EPSILON (1e-6)
diff --git a/src/libs/zbxalgo/queue.c b/src/libs/zbxalgo/queue.c
index 3ae69e445e4..a2feaf44049 100644
--- a/src/libs/zbxalgo/queue.c
+++ b/src/libs/zbxalgo/queue.c
@@ -17,9 +17,10 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
#include "zbxalgo.h"
+#include "common.h"
+
/******************************************************************************
* *
* Purpose: calculates the number of values in queue *
diff --git a/src/libs/zbxalgo/serialize.c b/src/libs/zbxalgo/serialize.c
index c045b2f4b8a..91284c33a9f 100644
--- a/src/libs/zbxalgo/serialize.c
+++ b/src/libs/zbxalgo/serialize.c
@@ -17,9 +17,10 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
+#include "zbxserialize.h"
+
#include "string.h"
#include "zbxtypes.h"
-#include "zbxserialize.h"
/******************************************************************************
* *
diff --git a/src/libs/zbxalgo/vector.c b/src/libs/zbxalgo/vector.c
index 18b4debcaa5..8f922a2729d 100644
--- a/src/libs/zbxalgo/vector.c
+++ b/src/libs/zbxalgo/vector.c
@@ -17,10 +17,9 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
-
#include "zbxalgo.h"
-#include "vectorimpl.h"
+
+#include "common.h"
ZBX_VECTOR_IMPL(uint64, zbx_uint64_t)
ZBX_PTR_VECTOR_IMPL(str, char *)
diff --git a/src/libs/zbxalgo/vectorimpl.h b/src/libs/zbxalgo/vectorimpl.h
deleted file mode 100644
index 6323f2c45f7..00000000000
--- a/src/libs/zbxalgo/vectorimpl.h
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
-** Zabbix
-** Copyright (C) 2001-2022 Zabbix SIA
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-**
-** 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 General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-**/
-
-#ifndef ZABBIX_VECTORIMPL_H
-#define ZABBIX_VECTORIMPL_H
-
-#define ZBX_VECTOR_ARRAY_GROWTH_FACTOR 3/2
-
-#include "log.h"
-
-#define ZBX_VECTOR_IMPL(__id, __type) \
- \
-static void __vector_ ## __id ## _ensure_free_space(zbx_vector_ ## __id ## _t *vector) \
-{ \
- if (NULL == vector->values) \
- { \
- vector->values_num = 0; \
- vector->values_alloc = 32; \
- vector->values = (__type *)vector->mem_malloc_func(NULL, (size_t)vector->values_alloc * \
- sizeof(__type)); \
- } \
- else if (vector->values_num == vector->values_alloc) \
- { \
- vector->values_alloc = MAX(vector->values_alloc + 1, vector->values_alloc * \
- ZBX_VECTOR_ARRAY_GROWTH_FACTOR); \
- vector->values = (__type *)vector->mem_realloc_func(vector->values, \
- (size_t)vector->values_alloc * sizeof(__type)); \
- } \
-} \
- \
-void zbx_vector_ ## __id ## _create(zbx_vector_ ## __id ## _t *vector) \
-{ \
- zbx_vector_ ## __id ## _create_ext(vector, \
- ZBX_DEFAULT_MEM_MALLOC_FUNC, \
- ZBX_DEFAULT_MEM_REALLOC_FUNC, \
- ZBX_DEFAULT_MEM_FREE_FUNC); \
-} \
- \
-void zbx_vector_ ## __id ## _create_ext(zbx_vector_ ## __id ## _t *vector, \
- zbx_mem_malloc_func_t mem_malloc_func, \
- zbx_mem_realloc_func_t mem_realloc_func, \
- zbx_mem_free_func_t mem_free_func) \
-{ \
- vector->values = NULL; \
- vector->values_num = 0; \
- vector->values_alloc = 0; \
- \
- vector->mem_malloc_func = mem_malloc_func; \
- vector->mem_realloc_func = mem_realloc_func; \
- vector->mem_free_func = mem_free_func; \
-} \
- \
-void zbx_vector_ ## __id ## _destroy(zbx_vector_ ## __id ## _t *vector) \
-{ \
- if (NULL != vector->values) \
- { \
- vector->mem_free_func(vector->values); \
- vector->values = NULL; \
- vector->values_num = 0; \
- vector->values_alloc = 0; \
- } \
- \
- vector->mem_malloc_func = NULL; \
- vector->mem_realloc_func = NULL; \
- vector->mem_free_func = NULL; \
-} \
- \
-void zbx_vector_ ## __id ## _append(zbx_vector_ ## __id ## _t *vector, __type value) \
-{ \
- __vector_ ## __id ## _ensure_free_space(vector); \
- vector->values[vector->values_num++] = value; \
-} \
- \
-void zbx_vector_ ## __id ## _append_ptr(zbx_vector_ ## __id ## _t *vector, __type *value) \
-{ \
- __vector_ ## __id ## _ensure_free_space(vector); \
- vector->values[vector->values_num++] = *value; \
-} \
- \
-void zbx_vector_ ## __id ## _append_array(zbx_vector_ ## __id ## _t *vector, __type const *values, \
- int values_num) \
-{ \
- zbx_vector_ ## __id ## _reserve(vector, (size_t)(vector->values_num + values_num)); \
- memcpy(vector->values + vector->values_num, values, (size_t)values_num * sizeof(__type)); \
- vector->values_num = vector->values_num + values_num; \
-} \
- \
-void zbx_vector_ ## __id ## _remove_noorder(zbx_vector_ ## __id ## _t *vector, int index) \
-{ \
- if (!(0 <= index && index < vector->values_num)) \
- { \
- zabbix_log(LOG_LEVEL_CRIT, "removing a non-existent element at index %d", index); \
- exit(EXIT_FAILURE); \
- } \
- \
- vector->values[index] = vector->values[--vector->values_num]; \
-} \
- \
-void zbx_vector_ ## __id ## _remove(zbx_vector_ ## __id ## _t *vector, int index) \
-{ \
- if (!(0 <= index && index < vector->values_num)) \
- { \
- zabbix_log(LOG_LEVEL_CRIT, "removing a non-existent element at index %d", index); \
- exit(EXIT_FAILURE); \
- } \
- \
- vector->values_num--; \
- memmove(&vector->values[index], &vector->values[index + 1], \
- sizeof(__type) * (size_t)(vector->values_num - index)); \
-} \
- \
-void zbx_vector_ ## __id ## _sort(zbx_vector_ ## __id ## _t *vector, zbx_compare_func_t compare_func) \
-{ \
- if (2 <= vector->values_num) \
- qsort(vector->values, (size_t)vector->values_num, sizeof(__type), compare_func); \
-} \
- \
-void zbx_vector_ ## __id ## _uniq(zbx_vector_ ## __id ## _t *vector, zbx_compare_func_t compare_func) \
-{ \
- if (2 <= vector->values_num) \
- { \
- int i, j = 1; \
- \
- for (i = 1; i < vector->values_num; i++) \
- { \
- if (0 != compare_func(&vector->values[i - 1], &vector->values[i])) \
- vector->values[j++] = vector->values[i]; \
- } \
- \
- vector->values_num = j; \
- } \
-} \
- \
-int zbx_vector_ ## __id ## _nearestindex(const zbx_vector_ ## __id ## _t *vector, const __type value, \
- zbx_compare_func_t compare_func) \
-{ \
- int lo = 0, hi = vector->values_num, mid, c; \
- \
- while (1 <= hi - lo) \
- { \
- mid = (lo + hi) / 2; \
- \
- c = compare_func(&vector->values[mid], &value); \
- \
- if (0 > c) \
- { \
- lo = mid + 1; \
- } \
- else if (0 == c) \
- { \
- return mid; \
- } \
- else \
- hi = mid; \
- } \
- \
- return hi; \
-} \
- \
-int zbx_vector_ ## __id ## _bsearch(const zbx_vector_ ## __id ## _t *vector, const __type value, \
- zbx_compare_func_t compare_func) \
-{ \
- __type *ptr; \
- \
- ptr = (__type *)zbx_bsearch(&value, vector->values, (size_t)vector->values_num, sizeof(__type), \
- compare_func); \
- \
- if (NULL != ptr) \
- return (int)(ptr - vector->values); \
- else \
- return FAIL; \
-} \
- \
-int zbx_vector_ ## __id ## _lsearch(const zbx_vector_ ## __id ## _t *vector, const __type value, int *index,\
- zbx_compare_func_t compare_func) \
-{ \
- while (*index < vector->values_num) \
- { \
- int c = compare_func(&vector->values[*index], &value); \
- \
- if (0 > c) \
- { \
- (*index)++; \
- continue; \
- } \
- \
- if (0 == c) \
- return SUCCEED; \
- \
- if (0 < c) \
- break; \
- } \
- \
- return FAIL; \
-} \
- \
-int zbx_vector_ ## __id ## _search(const zbx_vector_ ## __id ## _t *vector, const __type value, \
- zbx_compare_func_t compare_func) \
-{ \
- int index; \
- \
- for (index = 0; index < vector->values_num; index++) \
- { \
- if (0 == compare_func(&vector->values[index], &value)) \
- return index; \
- } \
- \
- return FAIL; \
-} \
- \
- \
-void zbx_vector_ ## __id ## _setdiff(zbx_vector_ ## __id ## _t *left, const zbx_vector_ ## __id ## _t *right,\
- zbx_compare_func_t compare_func) \
-{ \
- int c, block_start, deleted = 0, left_index = 0, right_index = 0; \
- \
- while (left_index < left->values_num && right_index < right->values_num) \
- { \
- c = compare_func(&left->values[left_index], &right->values[right_index]); \
- \
- if (0 >= c) \
- left_index++; \
- \
- if (0 <= c) \
- right_index++; \
- \
- if (0 != c) \
- continue; \
- \
- if (0 < deleted++) \
- { \
- memmove(&left->values[block_start - deleted + 1], &left->values[block_start], \
- (size_t)(left_index - 1 - block_start) * sizeof(__type)); \
- } \
- \
- block_start = left_index; \
- } \
- \
- if (0 < deleted) \
- { \
- memmove(&left->values[block_start - deleted], &left->values[block_start], \
- (size_t)(left->values_num - block_start) * sizeof(__type)); \
- left->values_num -= deleted; \
- } \
-} \
- \
-void zbx_vector_ ## __id ## _reserve(zbx_vector_ ## __id ## _t *vector, size_t size) \
-{ \
- if ((int)size > vector->values_alloc) \
- { \
- vector->values_alloc = (int)size; \
- vector->values = (__type *)vector->mem_realloc_func(vector->values, \
- (size_t)vector->values_alloc * sizeof(__type)); \
- } \
-} \
- \
-void zbx_vector_ ## __id ## _clear(zbx_vector_ ## __id ## _t *vector) \
-{ \
- vector->values_num = 0; \
-}
-
-#define ZBX_PTR_VECTOR_IMPL(__id, __type) \
- \
-ZBX_VECTOR_IMPL(__id, __type) \
- \
-void zbx_vector_ ## __id ## _clear_ext(zbx_vector_ ## __id ## _t *vector, \
- zbx_ ## __id ## _free_func_t free_func) \
-{ \
- if (0 != vector->values_num) \
- { \
- int index; \
- \
- for (index = 0; index < vector->values_num; index++) \
- free_func(vector->values[index]); \
- \
- vector->values_num = 0; \
- } \
-}
-
-#endif /* ZABBIX_VECTORIMPL_H */
diff --git a/src/libs/zbxcommon/variant.c b/src/libs/zbxcommon/variant.c
index aee2dadd6f5..9c3428b8c18 100644
--- a/src/libs/zbxcommon/variant.c
+++ b/src/libs/zbxcommon/variant.c
@@ -17,11 +17,10 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
-#include "log.h"
#include "zbxvariant.h"
-#include "../zbxalgo/vectorimpl.h"
+#include "common.h"
+#include "log.h"
ZBX_VECTOR_IMPL(var, zbx_variant_t)
diff --git a/src/libs/zbxcomms/Makefile.am b/src/libs/zbxcomms/Makefile.am
index 6821cd8a8a0..77105624244 100644
--- a/src/libs/zbxcomms/Makefile.am
+++ b/src/libs/zbxcomms/Makefile.am
@@ -3,6 +3,7 @@
noinst_LIBRARIES = libzbxcomms.a
libzbxcomms_a_SOURCES = \
+ comms.h \
comms.c \
telnet.c
diff --git a/src/libs/zbxcomms/comms.c b/src/libs/zbxcomms/comms.c
index 151ecb6aec4..a66a5d803fa 100644
--- a/src/libs/zbxcomms/comms.c
+++ b/src/libs/zbxcomms/comms.c
@@ -18,6 +18,7 @@
**/
#include "zbxcomms.h"
+#include "comms.h"
#include "common.h"
#include "base64.h"
diff --git a/src/libs/zbxcomms/comms.h b/src/libs/zbxcomms/comms.h
new file mode 100644
index 00000000000..f862b2ee63b
--- /dev/null
+++ b/src/libs/zbxcomms/comms.h
@@ -0,0 +1,43 @@
+/*
+** Zabbix
+** Copyright (C) 2001-2022 Zabbix SIA
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** 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 General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+**/
+
+#ifndef ZABBIX_COMMS_H
+#define ZABBIX_COMMS_H
+
+#include "config.h"
+
+#ifdef _WINDOWS
+# define ZBX_TCP_WRITE(s, b, bl) ((ssize_t)send((s), (b), (int)(bl), 0))
+# define ZBX_TCP_READ(s, b, bl) ((ssize_t)recv((s), (b), (int)(bl), 0))
+# define zbx_socket_close(s) if (ZBX_SOCKET_ERROR != (s)) closesocket(s)
+# define zbx_bind(s, a, l) (bind((s), (a), (int)(l)))
+# define zbx_sendto(fd, b, n, f, a, l) (sendto((fd), (b), (int)(n), (f), (a), (l)))
+# define ZBX_PROTO_AGAIN WSAEINTR
+# define ZBX_SOCKET_ERROR INVALID_SOCKET
+#else
+# define ZBX_TCP_WRITE(s, b, bl) ((ssize_t)write((s), (b), (bl)))
+# define ZBX_TCP_READ(s, b, bl) ((ssize_t)read((s), (b), (bl)))
+# define zbx_socket_close(s) if (ZBX_SOCKET_ERROR != (s)) close(s)
+# define zbx_bind(s, a, l) (bind((s), (a), (l)))
+# define zbx_sendto(fd, b, n, f, a, l) (sendto((fd), (b), (n), (f), (a), (l)))
+# define ZBX_PROTO_AGAIN EINTR
+# define ZBX_SOCKET_ERROR -1
+#endif
+
+#endif /* ZABBIX_COMMS_H */
diff --git a/src/libs/zbxcomms/telnet.c b/src/libs/zbxcomms/telnet.c
index 79c7ddf714a..c5ca664173c 100644
--- a/src/libs/zbxcomms/telnet.c
+++ b/src/libs/zbxcomms/telnet.c
@@ -17,11 +17,22 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "telnet.h"
+#include "zbxcomms.h"
+#include "comms.h"
#include "common.h"
#include "log.h"
+#define WAIT_READ 0
+#define WAIT_WRITE 1
+
+#define CMD_IAC 255
+#define CMD_WILL 251
+#define CMD_WONT 252
+#define CMD_DO 253
+#define CMD_DONT 254
+#define OPT_SGA 3
+
static char prompt_char = '\0';
static int telnet_waitsocket(ZBX_SOCKET socket_fd, int mode)
@@ -125,6 +136,9 @@ static ssize_t telnet_socket_write(ZBX_SOCKET socket_fd, const void *buf, size_t
return rc;
}
+#undef WAIT_READ
+#undef WAIT_WRITE
+
static ssize_t telnet_read(ZBX_SOCKET socket_fd, char *buf, size_t *buf_left, size_t *buf_offset)
{
unsigned char c, c1, c2, c3;
@@ -208,6 +222,13 @@ end:
return rc;
}
+#undef CMD_IAC
+#undef CMD_WILL
+#undef CMD_WONT
+#undef CMD_DO
+#undef CMD_DONT
+#undef OPT_SGA
+
/******************************************************************************
* *
* Comments: converts CR+LF to Unix LF and clears CR+NUL *
@@ -305,7 +326,7 @@ static void telnet_rm_prompt(const char *buf, size_t *offset)
}
}
-int telnet_test_login(ZBX_SOCKET socket_fd)
+int zbx_telnet_test_login(ZBX_SOCKET socket_fd)
{
char buf[MAX_BUFFER_LEN];
size_t sz, offset;
@@ -332,7 +353,7 @@ int telnet_test_login(ZBX_SOCKET socket_fd)
return ret;
}
-int telnet_login(ZBX_SOCKET socket_fd, const char *username, const char *password, AGENT_RESULT *result)
+int zbx_telnet_login(ZBX_SOCKET socket_fd, const char *username, const char *password, AGENT_RESULT *result)
{
char buf[MAX_BUFFER_LEN], c;
size_t sz, offset;
@@ -407,7 +428,7 @@ fail:
return ret;
}
-int telnet_execute(ZBX_SOCKET socket_fd, const char *command, AGENT_RESULT *result, const char *encoding)
+int zbx_telnet_execute(ZBX_SOCKET socket_fd, const char *command, AGENT_RESULT *result, const char *encoding)
{
char buf[MAX_BUFFER_LEN];
size_t sz, offset;
@@ -433,6 +454,7 @@ int telnet_execute(ZBX_SOCKET socket_fd, const char *command, AGENT_RESULT *resu
sz = sizeof(buf);
offset = 0;
+
while (ZBX_PROTO_ERROR != (rc = telnet_read(socket_fd, buf, &sz, &offset)))
{
if (prompt_char == telnet_lastchar(buf, offset))
diff --git a/src/libs/zbxcommshigh/commshigh.c b/src/libs/zbxcommshigh/commshigh.c
index f632fbe5ac0..ff6ec916df4 100644
--- a/src/libs/zbxcommshigh/commshigh.c
+++ b/src/libs/zbxcommshigh/commshigh.c
@@ -24,7 +24,7 @@
#include "log.h"
#if !defined(_WINDOWS) && !defined(__MINGW32)
-#include "daemon.h"
+#include "zbxnix.h"
#endif
#include "zbxalgo.h"
diff --git a/src/libs/zbxdbcache/dbcache.c b/src/libs/zbxdbcache/dbcache.c
index 9a70b3bfe9c..67fe08ec054 100644
--- a/src/libs/zbxdbcache/dbcache.c
+++ b/src/libs/zbxdbcache/dbcache.c
@@ -29,14 +29,13 @@
#include "module.h"
#include "export.h"
#include "zbxhistory.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxavailability.h"
#include "zbxtrends.h"
-#include "../zbxalgo/vectorimpl.h"
-static zbx_mem_info_t *hc_index_mem = NULL;
-static zbx_mem_info_t *hc_mem = NULL;
-static zbx_mem_info_t *trend_mem = NULL;
+static zbx_shmem_info_t *hc_index_mem = NULL;
+static zbx_shmem_info_t *hc_mem = NULL;
+static zbx_shmem_info_t *trend_mem = NULL;
#define LOCK_CACHE zbx_mutex_lock(cache_lock)
#define UNLOCK_CACHE zbx_mutex_unlock(cache_lock)
@@ -409,7 +408,7 @@ static void dc_insert_trends_in_db(ZBX_DC_TREND *trends, int trends_num, unsigne
zbx_uint128_t avg;
/* calculate the trend average value */
- udiv128_64(&avg, &trend->value_avg.ui64, trend->num);
+ zbx_udiv128_64(&avg, &trend->value_avg.ui64, trend->num);
zbx_db_insert_add_values(&db_insert, trend->itemid, trend->clock, trend->num,
trend->value_min.ui64, avg.lo, trend->value_max.ui64);
@@ -544,9 +543,9 @@ static void dc_trends_update_uint(ZBX_DC_TREND *trend, DB_ROW row, int num, size
trend->value_max.ui64 = value_max.ui64;
/* calculate the trend average value */
- umul64_64(&avg, num, value_avg.ui64);
- uinc128_128(&trend->value_avg.ui64, &avg);
- udiv128_64(&avg, &trend->value_avg.ui64, trend->num + num);
+ zbx_umul64_64(&avg, num, value_avg.ui64);
+ zbx_uinc128_128(&trend->value_avg.ui64, &avg);
+ zbx_udiv128_64(&avg, &trend->value_avg.ui64, trend->num + num);
trend->num += num;
@@ -819,7 +818,7 @@ static void DCadd_trend(const ZBX_DC_HISTORY *history, ZBX_DC_TREND **trends, in
trend->value_min.ui64 = history->value.ui64;
if (trend->num == 0 || history->value.ui64 > trend->value_max.ui64)
trend->value_max.ui64 = history->value.ui64;
- uinc128_64(&trend->value_avg.ui64, history->value.ui64);
+ zbx_uinc128_64(&trend->value_avg.ui64, history->value.ui64);
break;
}
trend->num++;
@@ -1189,7 +1188,7 @@ static void DCexport_trends(const ZBX_DC_TREND *trends, int trends_num, zbx_hash
break;
case ITEM_VALUE_TYPE_UINT64:
zbx_json_adduint64(&json, ZBX_PROTO_TAG_MIN, trend->value_min.ui64);
- udiv128_64(&avg, &trend->value_avg.ui64, trend->num);
+ zbx_udiv128_64(&avg, &trend->value_avg.ui64, trend->num);
zbx_json_adduint64(&json, ZBX_PROTO_TAG_AVG, avg.lo);
zbx_json_adduint64(&json, ZBX_PROTO_TAG_MAX, trend->value_max.ui64);
break;
@@ -1898,6 +1897,9 @@ static void normalize_item_value(const DC_ITEM *item, ZBX_DC_HISTORY *hdata)
zbx_variant_set_str(&value_var, hdata->value.log->value);
hdata->value.log->value = NULL;
break;
+ default:
+ THIS_SHOULD_NEVER_HAPPEN;
+ return;
}
dc_history_set_value(hdata, item->value_type, &value_var);
@@ -3912,8 +3914,8 @@ void dc_flush_history(void)
* history cache storage *
* *
******************************************************************************/
-ZBX_MEM_FUNC_IMPL(__hc_index, hc_index_mem)
-ZBX_MEM_FUNC_IMPL(__hc, hc_mem)
+ZBX_SHMEM_FUNC_IMPL(__hc_index, hc_index_mem)
+ZBX_SHMEM_FUNC_IMPL(__hc, hc_mem)
/******************************************************************************
* *
@@ -3943,7 +3945,7 @@ static void hc_free_data(zbx_hc_data_t *data)
{
if (ITEM_STATE_NOTSUPPORTED == data->state)
{
- __hc_mem_free_func(data->value.str);
+ __hc_shmem_free_func(data->value.str);
}
else
{
@@ -3953,21 +3955,21 @@ static void hc_free_data(zbx_hc_data_t *data)
{
case ITEM_VALUE_TYPE_STR:
case ITEM_VALUE_TYPE_TEXT:
- __hc_mem_free_func(data->value.str);
+ __hc_shmem_free_func(data->value.str);
break;
case ITEM_VALUE_TYPE_LOG:
- __hc_mem_free_func(data->value.log->value);
+ __hc_shmem_free_func(data->value.log->value);
if (NULL != data->value.log->source)
- __hc_mem_free_func(data->value.log->source);
+ __hc_shmem_free_func(data->value.log->source);
- __hc_mem_free_func(data->value.log);
+ __hc_shmem_free_func(data->value.log);
break;
}
}
}
- __hc_mem_free_func(data);
+ __hc_shmem_free_func(data);
}
/******************************************************************************
@@ -4029,7 +4031,7 @@ static char *hc_mem_value_str_dup(const dc_value_str_t *str)
{
char *ptr;
- if (NULL == (ptr = (char *)__hc_mem_malloc_func(NULL, str->len)))
+ if (NULL == (ptr = (char *)__hc_shmem_malloc_func(NULL, str->len)))
return NULL;
memcpy(ptr, &string_values[str->pvalue], str->len - 1);
@@ -4087,7 +4089,7 @@ static int hc_clone_history_log_data(zbx_log_value_t **dst, const dc_item_value_
if (NULL == *dst)
{
/* using realloc instead of malloc just to suppress 'not used' warning for realloc */
- if (NULL == (*dst = (zbx_log_value_t *)__hc_mem_realloc_func(NULL, sizeof(zbx_log_value_t))))
+ if (NULL == (*dst = (zbx_log_value_t *)__hc_shmem_realloc_func(NULL, sizeof(zbx_log_value_t))))
return FAIL;
memset(*dst, 0, sizeof(zbx_log_value_t));
@@ -4124,7 +4126,7 @@ static int hc_clone_history_data(zbx_hc_data_t **data, const dc_item_value_t *it
{
if (NULL == *data)
{
- if (NULL == (*data = (zbx_hc_data_t *)__hc_mem_malloc_func(NULL, sizeof(zbx_hc_data_t))))
+ if (NULL == (*data = (zbx_hc_data_t *)__hc_shmem_malloc_func(NULL, sizeof(zbx_hc_data_t))))
return FAIL;
memset(*data, 0, sizeof(zbx_hc_data_t));
@@ -4487,7 +4489,7 @@ int hc_get_history_compression_age(void)
* *
******************************************************************************/
-ZBX_MEM_FUNC_IMPL(__trend, trend_mem)
+ZBX_SHMEM_FUNC_IMPL(__trend, trend_mem)
static int init_trend_cache(char **error)
{
@@ -4499,8 +4501,8 @@ static int init_trend_cache(char **error)
if (SUCCEED != (ret = zbx_mutex_create(&trends_lock, ZBX_MUTEX_TRENDS, error)))
goto out;
- sz = zbx_mem_required_size(1, "trend cache", "TrendCacheSize");
- if (SUCCEED != (ret = zbx_mem_create(&trend_mem, CONFIG_TRENDS_CACHE_SIZE, "trend cache", "TrendCacheSize", 0,
+ sz = zbx_shmem_required_size(1, "trend cache", "TrendCacheSize");
+ if (SUCCEED != (ret = zbx_shmem_create(&trend_mem, CONFIG_TRENDS_CACHE_SIZE, "trend cache", "TrendCacheSize", 0,
error)))
{
goto out;
@@ -4517,7 +4519,7 @@ static int init_trend_cache(char **error)
zbx_hashset_create_ext(&cache->trends, INIT_HASHSET_SIZE,
ZBX_DEFAULT_UINT64_HASH_FUNC, ZBX_DEFAULT_UINT64_COMPARE_FUNC, NULL,
- __trend_mem_malloc_func, __trend_mem_realloc_func, __trend_mem_free_func);
+ __trend_shmem_malloc_func, __trend_shmem_realloc_func, __trend_shmem_free_func);
#undef INIT_HASHSET_SIZE
out:
@@ -4549,38 +4551,39 @@ int init_database_cache(char **error)
if (SUCCEED != (ret = zbx_mutex_create(&cache_ids_lock, ZBX_MUTEX_CACHE_IDS, error)))
goto out;
- if (SUCCEED != (ret = zbx_mem_create(&hc_mem, CONFIG_HISTORY_CACHE_SIZE, "history cache",
+ if (SUCCEED != (ret = zbx_shmem_create(&hc_mem, CONFIG_HISTORY_CACHE_SIZE, "history cache",
"HistoryCacheSize", 1, error)))
{
goto out;
}
- if (SUCCEED != (ret = zbx_mem_create(&hc_index_mem, CONFIG_HISTORY_INDEX_CACHE_SIZE, "history index cache",
+ if (SUCCEED != (ret = zbx_shmem_create(&hc_index_mem, CONFIG_HISTORY_INDEX_CACHE_SIZE, "history index cache",
"HistoryIndexCacheSize", 0, error)))
{
goto out;
}
- cache = (ZBX_DC_CACHE *)__hc_index_mem_malloc_func(NULL, sizeof(ZBX_DC_CACHE));
+ cache = (ZBX_DC_CACHE *)__hc_index_shmem_malloc_func(NULL, sizeof(ZBX_DC_CACHE));
memset(cache, 0, sizeof(ZBX_DC_CACHE));
- ids = (ZBX_DC_IDS *)__hc_index_mem_malloc_func(NULL, sizeof(ZBX_DC_IDS));
+ ids = (ZBX_DC_IDS *)__hc_index_shmem_malloc_func(NULL, sizeof(ZBX_DC_IDS));
memset(ids, 0, sizeof(ZBX_DC_IDS));
zbx_hashset_create_ext(&cache->history_items, ZBX_HC_ITEMS_INIT_SIZE,
ZBX_DEFAULT_UINT64_HASH_FUNC, ZBX_DEFAULT_UINT64_COMPARE_FUNC, NULL,
- __hc_index_mem_malloc_func, __hc_index_mem_realloc_func, __hc_index_mem_free_func);
+ __hc_index_shmem_malloc_func, __hc_index_shmem_realloc_func, __hc_index_shmem_free_func);
zbx_binary_heap_create_ext(&cache->history_queue, hc_queue_elem_compare_func, ZBX_BINARY_HEAP_OPTION_EMPTY,
- __hc_index_mem_malloc_func, __hc_index_mem_realloc_func, __hc_index_mem_free_func);
+ __hc_index_shmem_malloc_func, __hc_index_shmem_realloc_func, __hc_index_shmem_free_func);
if (0 != (program_type & ZBX_PROGRAM_TYPE_SERVER))
{
zbx_hashset_create_ext(&(cache->proxyqueue.index), ZBX_HC_SYNC_MAX,
ZBX_DEFAULT_UINT64_HASH_FUNC, ZBX_DEFAULT_UINT64_COMPARE_FUNC, NULL,
- __hc_index_mem_malloc_func, __hc_index_mem_realloc_func, __hc_index_mem_free_func);
+ __hc_index_shmem_malloc_func, __hc_index_shmem_realloc_func, __hc_index_shmem_free_func);
- zbx_list_create_ext(&(cache->proxyqueue.list), __hc_index_mem_malloc_func, __hc_index_mem_free_func);
+ zbx_list_create_ext(&(cache->proxyqueue.list), __hc_index_shmem_malloc_func,
+ __hc_index_shmem_free_func);
cache->proxyqueue.state = ZBX_HC_PROXYQUEUE_STATE_NORMAL;
@@ -4676,9 +4679,9 @@ void free_database_cache(int sync)
cache = NULL;
- zbx_mem_destroy(hc_mem);
+ zbx_shmem_destroy(hc_mem);
hc_mem = NULL;
- zbx_mem_destroy(hc_index_mem);
+ zbx_shmem_destroy(hc_index_mem);
hc_index_mem = NULL;
zbx_mutex_destroy(&cache_lock);
@@ -4686,7 +4689,7 @@ void free_database_cache(int sync)
if (0 != (program_type & ZBX_PROGRAM_TYPE_SERVER))
{
- zbx_mem_destroy(trend_mem);
+ zbx_shmem_destroy(trend_mem);
trend_mem = NULL;
zbx_mutex_destroy(&trends_lock);
}
@@ -4815,15 +4818,15 @@ void zbx_hc_get_diag_stats(zbx_uint64_t *items_num, zbx_uint64_t *values_num)
* Purpose: get shared memory allocator statistics *
* *
******************************************************************************/
-void zbx_hc_get_mem_stats(zbx_mem_stats_t *data, zbx_mem_stats_t *index)
+void zbx_hc_get_mem_stats(zbx_shmem_stats_t *data, zbx_shmem_stats_t *index)
{
LOCK_CACHE;
if (NULL != data)
- zbx_mem_get_stats(hc_mem, data);
+ zbx_shmem_get_stats(hc_mem, data);
if (NULL != index)
- zbx_mem_get_stats(hc_index_mem, index);
+ zbx_shmem_get_stats(hc_index_mem, index);
UNLOCK_CACHE;
}
diff --git a/src/libs/zbxdbcache/dbconfig.c b/src/libs/zbxdbcache/dbconfig.c
index e60b34cb83a..d8f3efceafb 100644
--- a/src/libs/zbxdbcache/dbconfig.c
+++ b/src/libs/zbxdbcache/dbconfig.c
@@ -26,7 +26,6 @@
#include "cfg.h"
#include "zbxhash.h"
#include "../zbxcrypto/tls_tcp_active.h"
-#include "../zbxalgo/vectorimpl.h"
#include "../zbxkvs/kvs.h"
#include "../zbxvault/vault.h"
#include "base64.h"
@@ -81,14 +80,14 @@ int sync_in_progress = 0;
******************************************************************************/
typedef int (*zbx_value_validator_func_t)(const char *macro, const char *value, char **error);
-ZBX_DC_CONFIG *config = NULL;
-zbx_rwlock_t config_lock = ZBX_RWLOCK_NULL;
-static zbx_mem_info_t *config_mem;
+ZBX_DC_CONFIG *config = NULL;
+zbx_rwlock_t config_lock = ZBX_RWLOCK_NULL;
+static zbx_shmem_info_t *config_mem;
extern unsigned char program_type;
extern int CONFIG_TIMER_FORKS;
-ZBX_MEM_FUNC_IMPL(__config, config_mem)
+ZBX_SHMEM_FUNC_IMPL(__config, config_mem)
static void dc_maintenance_precache_nested_groups(void);
static void dc_item_reset_triggers(ZBX_DC_ITEM *item, ZBX_DC_TRIGGER *trigger_exclude);
@@ -109,7 +108,7 @@ static char *dc_strdup(const char *source)
size_t len;
len = strlen(source) + 1;
- dst = (char *)__config_mem_malloc_func(NULL, len);
+ dst = (char *)__config_shmem_malloc_func(NULL, len);
memcpy(dst, source, len);
return dst;
}
@@ -648,10 +647,11 @@ static ZBX_DC_GMACRO_M *config_gmacro_add_index(zbx_hashset_t *gmacro_index, ZBX
if (NULL == (gmacro_m = (ZBX_DC_GMACRO_M *)zbx_hashset_search(gmacro_index, &gmacro_m_local)))
{
gmacro_m_local.macro = zbx_strpool_acquire(gmacro->macro);
- zbx_vector_ptr_create_ext(&gmacro_m_local.gmacros, __config_mem_malloc_func, __config_mem_realloc_func,
- __config_mem_free_func);
+ zbx_vector_ptr_create_ext(&gmacro_m_local.gmacros, __config_shmem_malloc_func,
+ __config_shmem_realloc_func, __config_shmem_free_func);
- gmacro_m = (ZBX_DC_GMACRO_M *)zbx_hashset_insert(gmacro_index, &gmacro_m_local, sizeof(ZBX_DC_GMACRO_M));
+ gmacro_m = (ZBX_DC_GMACRO_M *)zbx_hashset_insert(gmacro_index, &gmacro_m_local,
+ sizeof(ZBX_DC_GMACRO_M));
}
zbx_vector_ptr_append(&gmacro_m->gmacros, gmacro);
@@ -723,10 +723,11 @@ static ZBX_DC_HMACRO_HM *config_hmacro_add_index(zbx_hashset_t *hmacro_index, ZB
if (NULL == (hmacro_hm = (ZBX_DC_HMACRO_HM *)zbx_hashset_search(hmacro_index, &hmacro_hm_local)))
{
hmacro_hm_local.macro = zbx_strpool_acquire(hmacro->macro);
- zbx_vector_ptr_create_ext(&hmacro_hm_local.hmacros, __config_mem_malloc_func, __config_mem_realloc_func,
- __config_mem_free_func);
+ zbx_vector_ptr_create_ext(&hmacro_hm_local.hmacros, __config_shmem_malloc_func,
+ __config_shmem_realloc_func, __config_shmem_free_func);
- hmacro_hm = (ZBX_DC_HMACRO_HM *)zbx_hashset_insert(hmacro_index, &hmacro_hm_local, sizeof(ZBX_DC_HMACRO_HM));
+ hmacro_hm = (ZBX_DC_HMACRO_HM *)zbx_hashset_insert(hmacro_index, &hmacro_hm_local,
+ sizeof(ZBX_DC_HMACRO_HM));
}
zbx_vector_ptr_append(&hmacro_hm->hmacros, hmacro);
@@ -809,12 +810,12 @@ static zbx_dc_kv_t *config_kvs_path_add(const char *path, const char *key)
if (FAIL == (i = zbx_vector_ptr_search(&config->kvs_paths, &kvs_path_local, dc_compare_kvs_path)))
{
- kvs_path = (zbx_dc_kvs_path_t *)__config_mem_malloc_func(NULL, sizeof(zbx_dc_kvs_path_t));
+ kvs_path = (zbx_dc_kvs_path_t *)__config_shmem_malloc_func(NULL, sizeof(zbx_dc_kvs_path_t));
DCstrpool_replace(0, &kvs_path->path, path);
zbx_vector_ptr_append(&config->kvs_paths, kvs_path);
zbx_hashset_create_ext(&kvs_path->kvs, 0, dc_kv_hash, dc_kv_compare, NULL,
- __config_mem_malloc_func, __config_mem_realloc_func, __config_mem_free_func);
+ __config_shmem_malloc_func, __config_shmem_realloc_func, __config_shmem_free_func);
kv = NULL;
}
else
@@ -868,7 +869,7 @@ static void config_kvs_path_remove(const char *value, zbx_dc_kv_t *kv)
if (0 == kvs_path->kvs.num_data)
{
zbx_strpool_release(kvs_path->path);
- __config_mem_free_func(kvs_path);
+ __config_shmem_free_func(kvs_path);
zbx_vector_ptr_remove_noorder(&config->kvs_paths, i);
}
clean:
@@ -929,7 +930,7 @@ static int DCsync_config(zbx_dbsync_t *sync, int *flags)
if (NULL == config->config)
{
found = 0;
- config->config = (ZBX_DC_CONFIG_TABLE *)__config_mem_malloc_func(NULL, sizeof(ZBX_DC_CONFIG_TABLE));
+ config->config = (ZBX_DC_CONFIG_TABLE *)__config_shmem_malloc_func(NULL, sizeof(ZBX_DC_CONFIG_TABLE));
}
if (SUCCEED != (ret = zbx_dbsync_next(sync, &rowid, &db_row, &tag)))
@@ -1423,8 +1424,8 @@ done:
host->data_expected_from = now;
host->update_items = 0;
- zbx_vector_ptr_create_ext(&host->interfaces_v, __config_mem_malloc_func,
- __config_mem_realloc_func, __config_mem_free_func);
+ zbx_vector_ptr_create_ext(&host->interfaces_v, __config_shmem_malloc_func,
+ __config_shmem_realloc_func, __config_shmem_free_func);
}
else
{
@@ -1735,9 +1736,9 @@ static void DCsync_htmpls(zbx_dbsync_t *sync)
if (0 == found)
{
zbx_vector_uint64_create_ext(&htmpl->templateids,
- __config_mem_malloc_func,
- __config_mem_realloc_func,
- __config_mem_free_func);
+ __config_shmem_malloc_func,
+ __config_shmem_realloc_func,
+ __config_shmem_free_func);
zbx_vector_uint64_reserve(&htmpl->templateids, 1);
}
@@ -2138,7 +2139,8 @@ void DCsync_kvs_paths(const struct zbx_json_parse *jp_kvs_paths)
}
else if (FAIL == zbx_vault_kvs_get(dc_kvs_path->path, &kvs, &error))
{
- zabbix_log(LOG_LEVEL_WARNING, "cannot get secrets for path \"%s\": %s", dc_kvs_path->path, error);
+ zabbix_log(LOG_LEVEL_WARNING, "cannot get secrets for path \"%s\": %s", dc_kvs_path->path,
+ error);
zbx_free(error);
continue;
}
@@ -2471,9 +2473,9 @@ static void DCsync_interfaces(zbx_dbsync_t *sync)
interface_snmpaddr = (ZBX_DC_INTERFACE_ADDR *)zbx_hashset_insert(&config->interface_snmpaddrs,
&interface_snmpaddr_local, sizeof(ZBX_DC_INTERFACE_ADDR));
zbx_vector_uint64_create_ext(&interface_snmpaddr->interfaceids,
- __config_mem_malloc_func,
- __config_mem_realloc_func,
- __config_mem_free_func);
+ __config_shmem_malloc_func,
+ __config_shmem_realloc_func,
+ __config_shmem_free_func);
}
zbx_vector_uint64_append(&interface_snmpaddr->interfaceids, interfaceid);
@@ -2695,7 +2697,7 @@ static unsigned char *config_decode_serialized_expression(const char *src)
return NULL;
src_len = strlen(src) * 3 / 4;
- dst = __config_mem_malloc_func(NULL, src_len);
+ dst = __config_shmem_malloc_func(NULL, src_len);
str_base64_decode(src, (char *)dst, src_len, &data_len);
return dst;
@@ -2839,8 +2841,8 @@ static void DCsync_items(zbx_dbsync_t *sync, int flags)
item->queue_priority = ZBX_QUEUE_PRIORITY_NORMAL;
item->schedulable = 1;
- zbx_vector_ptr_create_ext(&item->tags, __config_mem_malloc_func, __config_mem_realloc_func,
- __config_mem_free_func);
+ zbx_vector_ptr_create_ext(&item->tags, __config_shmem_malloc_func, __config_shmem_realloc_func,
+ __config_shmem_free_func);
}
else
{
@@ -3123,9 +3125,9 @@ static void DCsync_items(zbx_dbsync_t *sync, int flags)
if (0 == found)
{
zbx_vector_uint64_create_ext(&interface_snmpitem->itemids,
- __config_mem_malloc_func,
- __config_mem_realloc_func,
- __config_mem_free_func);
+ __config_shmem_malloc_func,
+ __config_shmem_realloc_func,
+ __config_shmem_free_func);
}
zbx_vector_uint64_append(&interface_snmpitem->itemids, itemid);
@@ -3141,7 +3143,7 @@ static void DCsync_items(zbx_dbsync_t *sync, int flags)
DCstrpool_replace(found, &calcitem->params, row[11]);
if (1 == found && NULL != calcitem->formula_bin)
- __config_mem_free_func((void *)calcitem->formula_bin);
+ __config_shmem_free_func((void *)calcitem->formula_bin);
calcitem->formula_bin = config_decode_serialized_expression(row[49]);
}
@@ -3150,7 +3152,7 @@ static void DCsync_items(zbx_dbsync_t *sync, int flags)
/* remove calculated item parameters */
if (NULL != calcitem->formula_bin)
- __config_mem_free_func((void *)calcitem->formula_bin);
+ __config_shmem_free_func((void *)calcitem->formula_bin);
zbx_strpool_release(calcitem->params);
zbx_hashset_remove_direct(&config->calcitems, calcitem);
}
@@ -3217,8 +3219,8 @@ static void DCsync_items(zbx_dbsync_t *sync, int flags)
if (0 == found)
{
- zbx_vector_ptr_create_ext(&scriptitem->params, __config_mem_malloc_func,
- __config_mem_realloc_func, __config_mem_free_func);
+ zbx_vector_ptr_create_ext(&scriptitem->params, __config_shmem_malloc_func,
+ __config_shmem_realloc_func, __config_shmem_free_func);
}
}
else if (NULL != (scriptitem = (ZBX_DC_SCRIPTITEM *)zbx_hashset_search(&config->scriptitems, &itemid)))
@@ -3292,8 +3294,8 @@ static void DCsync_items(zbx_dbsync_t *sync, int flags)
master_local.itemid = depitem->master_itemid;
master = (ZBX_DC_MASTERITEM *)zbx_hashset_insert(&config->masteritems, &master_local, sizeof(master_local));
- zbx_vector_uint64_pair_create_ext(&master->dep_itemids, __config_mem_malloc_func,
- __config_mem_realloc_func, __config_mem_free_func);
+ zbx_vector_uint64_pair_create_ext(&master->dep_itemids, __config_shmem_malloc_func,
+ __config_shmem_realloc_func, __config_shmem_free_func);
}
zbx_vector_uint64_pair_append(&master->dep_itemids, pair);
@@ -3446,7 +3448,7 @@ static void DCsync_items(zbx_dbsync_t *sync, int flags)
zbx_strpool_release(calcitem->params);
if (NULL != calcitem->formula_bin)
- __config_mem_free_func((void *)calcitem->formula_bin);
+ __config_shmem_free_func((void *)calcitem->formula_bin);
zbx_hashset_remove_direct(&config->calcitems, calcitem);
}
@@ -3689,17 +3691,17 @@ static void DCsync_triggers(zbx_dbsync_t *sync)
trigger->locked = 0;
trigger->timer_revision = 0;
- zbx_vector_ptr_create_ext(&trigger->tags, __config_mem_malloc_func, __config_mem_realloc_func,
- __config_mem_free_func);
+ zbx_vector_ptr_create_ext(&trigger->tags, __config_shmem_malloc_func,
+ __config_shmem_realloc_func, __config_shmem_free_func);
trigger->topoindex = 1;
trigger->itemids = NULL;
}
else
{
if (NULL != trigger->expression_bin)
- __config_mem_free_func((void *)trigger->expression_bin);
+ __config_shmem_free_func((void *)trigger->expression_bin);
if (NULL != trigger->recovery_expression_bin)
- __config_mem_free_func((void *)trigger->recovery_expression_bin);
+ __config_shmem_free_func((void *)trigger->recovery_expression_bin);
}
trigger->expression_bin = config_decode_serialized_expression(row[16]);
@@ -3745,12 +3747,12 @@ static void DCsync_triggers(zbx_dbsync_t *sync)
zbx_vector_ptr_destroy(&trigger->tags);
if (NULL != trigger->expression_bin)
- __config_mem_free_func((void *)trigger->expression_bin);
+ __config_shmem_free_func((void *)trigger->expression_bin);
if (NULL != trigger->recovery_expression_bin)
- __config_mem_free_func((void *)trigger->recovery_expression_bin);
+ __config_shmem_free_func((void *)trigger->recovery_expression_bin);
if (NULL != trigger->itemids)
- __config_mem_free_func((void *)trigger->itemids);
+ __config_shmem_free_func((void *)trigger->itemids);
}
zbx_hashset_remove_direct(&config->triggers, trigger);
@@ -3788,8 +3790,8 @@ static void dc_trigger_deplist_init(ZBX_DC_TRIGGER_DEPLIST *trigdep, ZBX_DC_TRIG
{
trigdep->refcount = 1;
trigdep->trigger = trigger;
- zbx_vector_ptr_create_ext(&trigdep->dependencies, __config_mem_malloc_func, __config_mem_realloc_func,
- __config_mem_free_func);
+ zbx_vector_ptr_create_ext(&trigdep->dependencies, __config_shmem_malloc_func, __config_shmem_realloc_func,
+ __config_shmem_free_func);
}
/******************************************************************************
@@ -3801,8 +3803,8 @@ static void dc_trigger_deplist_init(ZBX_DC_TRIGGER_DEPLIST *trigdep, ZBX_DC_TRIG
static void dc_trigger_deplist_reset(ZBX_DC_TRIGGER_DEPLIST *trigdep)
{
zbx_vector_ptr_destroy(&trigdep->dependencies);
- zbx_vector_ptr_create_ext(&trigdep->dependencies, __config_mem_malloc_func, __config_mem_realloc_func,
- __config_mem_free_func);
+ zbx_vector_ptr_create_ext(&trigdep->dependencies, __config_shmem_malloc_func, __config_shmem_realloc_func,
+ __config_shmem_free_func);
}
static void DCsync_trigdeps(zbx_dbsync_t *sync)
@@ -4018,7 +4020,7 @@ static zbx_trigger_timer_t *dc_trigger_function_timer_create(ZBX_DC_FUNCTION *fu
type = ZBX_TRIGGER_TIMER_FUNCTION_TIME;
}
- timer = (zbx_trigger_timer_t *)__config_mem_malloc_func(NULL, sizeof(zbx_trigger_timer_t));
+ timer = (zbx_trigger_timer_t *)__config_shmem_malloc_func(NULL, sizeof(zbx_trigger_timer_t));
timer->objectid = function->functionid;
timer->triggerid = function->triggerid;
@@ -4048,7 +4050,7 @@ static zbx_trigger_timer_t *dc_trigger_timer_create(ZBX_DC_TRIGGER *trigger)
{
zbx_trigger_timer_t *timer;
- timer = (zbx_trigger_timer_t *)__config_mem_malloc_func(NULL, sizeof(zbx_trigger_timer_t));
+ timer = (zbx_trigger_timer_t *)__config_shmem_malloc_func(NULL, sizeof(zbx_trigger_timer_t));
timer->type = ZBX_TRIGGER_TIMER_TRIGGER;
timer->objectid = trigger->triggerid;
timer->triggerid = trigger->triggerid;
@@ -4072,7 +4074,7 @@ static void dc_trigger_timer_free(zbx_trigger_timer_t *timer)
if (NULL != timer->parameter)
zbx_strpool_release(timer->parameter);
- __config_mem_free_func(timer);
+ __config_shmem_free_func(timer);
}
/******************************************************************************
@@ -4342,9 +4344,9 @@ static void DCsync_expressions(zbx_dbsync_t *sync)
{
DCstrpool_replace(0, &regexp_local.name, row[0]);
zbx_vector_uint64_create_ext(&regexp_local.expressionids,
- __config_mem_malloc_func,
- __config_mem_realloc_func,
- __config_mem_free_func);
+ __config_shmem_malloc_func,
+ __config_shmem_realloc_func,
+ __config_shmem_free_func);
regexp = (ZBX_DC_REGEXP *)zbx_hashset_insert(&config->regexps, &regexp_local, sizeof(ZBX_DC_REGEXP));
}
@@ -4432,8 +4434,8 @@ static void DCsync_actions(zbx_dbsync_t *sync)
if (EVENT_SOURCE_INTERNAL == action->eventsource)
config->internal_actions++;
- zbx_vector_ptr_create_ext(&action->conditions, __config_mem_malloc_func,
- __config_mem_realloc_func, __config_mem_free_func);
+ zbx_vector_ptr_create_ext(&action->conditions, __config_shmem_malloc_func,
+ __config_shmem_realloc_func, __config_shmem_free_func);
zbx_vector_ptr_reserve(&action->conditions, 1);
@@ -4649,11 +4651,11 @@ static void DCsync_correlations(zbx_dbsync_t *sync)
if (0 == found)
{
- zbx_vector_ptr_create_ext(&correlation->conditions, __config_mem_malloc_func,
- __config_mem_realloc_func, __config_mem_free_func);
+ zbx_vector_ptr_create_ext(&correlation->conditions, __config_shmem_malloc_func,
+ __config_shmem_realloc_func, __config_shmem_free_func);
- zbx_vector_ptr_create_ext(&correlation->operations, __config_mem_malloc_func,
- __config_mem_realloc_func, __config_mem_free_func);
+ zbx_vector_ptr_create_ext(&correlation->operations, __config_shmem_malloc_func,
+ __config_shmem_realloc_func, __config_shmem_free_func);
}
DCstrpool_replace(found, &correlation->name, row[1]);
@@ -5031,8 +5033,8 @@ static void DCsync_hostgroups(zbx_dbsync_t *sync)
zbx_vector_ptr_append(&config->hostgroups_name, group);
zbx_hashset_create_ext(&group->hostids, 0, ZBX_DEFAULT_UINT64_HASH_FUNC,
- ZBX_DEFAULT_UINT64_COMPARE_FUNC, NULL, __config_mem_malloc_func,
- __config_mem_realloc_func, __config_mem_free_func);
+ ZBX_DEFAULT_UINT64_COMPARE_FUNC, NULL, __config_shmem_malloc_func,
+ __config_shmem_realloc_func, __config_shmem_free_func);
}
DCstrpool_replace(found, &group->name, row[1]);
@@ -5130,8 +5132,8 @@ static void DCsync_trigger_tags(zbx_dbsync_t *sync)
if (0 == trigger->tags.values_num)
{
zbx_vector_ptr_destroy(&trigger->tags);
- zbx_vector_ptr_create_ext(&trigger->tags, __config_mem_malloc_func,
- __config_mem_realloc_func, __config_mem_free_func);
+ zbx_vector_ptr_create_ext(&trigger->tags, __config_shmem_malloc_func,
+ __config_shmem_realloc_func, __config_shmem_free_func);
}
}
}
@@ -5214,8 +5216,8 @@ static void DCsync_item_tags(zbx_dbsync_t *sync)
if (0 == item->tags.values_num)
{
zbx_vector_ptr_destroy(&item->tags);
- zbx_vector_ptr_create_ext(&item->tags, __config_mem_malloc_func,
- __config_mem_realloc_func, __config_mem_free_func);
+ zbx_vector_ptr_create_ext(&item->tags, __config_shmem_malloc_func,
+ __config_shmem_realloc_func, __config_shmem_free_func);
}
}
}
@@ -5281,8 +5283,8 @@ static void DCsync_host_tags(zbx_dbsync_t *sync)
if (0 == found)
{
- zbx_vector_ptr_create_ext(&host_tag_index_entry->tags, __config_mem_malloc_func,
- __config_mem_realloc_func, __config_mem_free_func);
+ zbx_vector_ptr_create_ext(&host_tag_index_entry->tags, __config_shmem_malloc_func,
+ __config_shmem_realloc_func, __config_shmem_free_func);
}
zbx_vector_ptr_append(&host_tag_index_entry->tags, host_tag);
@@ -5402,25 +5404,28 @@ static void DCsync_item_preproc(zbx_dbsync_t *sync, int timestamp)
if (NULL == preprocitem || itemid != preprocitem->itemid)
{
- if (NULL == (preprocitem = (ZBX_DC_PREPROCITEM *)zbx_hashset_search(&config->preprocitems, &itemid)))
+ if (NULL == (preprocitem = (ZBX_DC_PREPROCITEM *)zbx_hashset_search(&config->preprocitems,
+ &itemid)))
{
ZBX_DC_PREPROCITEM preprocitem_local;
preprocitem_local.itemid = itemid;
+ preprocitem_local.update_time = timestamp;
- preprocitem = (ZBX_DC_PREPROCITEM *)zbx_hashset_insert(&config->preprocitems, &preprocitem_local,
- sizeof(preprocitem_local));
+ zbx_vector_ptr_create_ext(&preprocitem_local.preproc_ops, __config_shmem_malloc_func,
+ __config_shmem_realloc_func, __config_shmem_free_func);
- zbx_vector_ptr_create_ext(&preprocitem->preproc_ops, __config_mem_malloc_func,
- __config_mem_realloc_func, __config_mem_free_func);
+ preprocitem = (ZBX_DC_PREPROCITEM *)zbx_hashset_insert(&config->preprocitems,
+ &preprocitem_local, sizeof(preprocitem_local));
}
-
- preprocitem->update_time = timestamp;
+ else
+ preprocitem->update_time = timestamp;
}
ZBX_STR2UINT64(item_preprocid, row[0]);
- op = (zbx_dc_preproc_op_t *)DCfind_id(&config->preprocops, item_preprocid, sizeof(zbx_dc_preproc_op_t), &found);
+ op = (zbx_dc_preproc_op_t *)DCfind_id(&config->preprocops, item_preprocid, sizeof(zbx_dc_preproc_op_t),
+ &found);
ZBX_STR2UCHAR(op->type, row[2]);
DCstrpool_replace(found, &op->params, row[3]);
@@ -5444,7 +5449,8 @@ static void DCsync_item_preproc(zbx_dbsync_t *sync, int timestamp)
if (NULL == (op = (zbx_dc_preproc_op_t *)zbx_hashset_search(&config->preprocops, &rowid)))
continue;
- if (NULL != (preprocitem = (ZBX_DC_PREPROCITEM *)zbx_hashset_search(&config->preprocitems, &op->itemid)))
+ if (NULL != (preprocitem = (ZBX_DC_PREPROCITEM *)zbx_hashset_search(&config->preprocitems,
+ &op->itemid)))
{
if (FAIL != (index = zbx_vector_ptr_search(&preprocitem->preproc_ops, op,
ZBX_DEFAULT_PTR_COMPARE_FUNC)))
@@ -5719,12 +5725,12 @@ static void dc_trigger_add_itemids(ZBX_DC_TRIGGER *trigger, const zbx_vector_uin
for (itemid = trigger->itemids; 0 != *itemid; itemid++)
itemids_num++;
- trigger->itemids = (zbx_uint64_t *)__config_mem_realloc_func(trigger->itemids,
+ trigger->itemids = (zbx_uint64_t *)__config_shmem_realloc_func(trigger->itemids,
sizeof(zbx_uint64_t) * (size_t)(itemids->values_num + itemids_num + 1));
}
else
{
- trigger->itemids = (zbx_uint64_t *)__config_mem_malloc_func(trigger->itemids,
+ trigger->itemids = (zbx_uint64_t *)__config_shmem_malloc_func(trigger->itemids,
sizeof(zbx_uint64_t) * (size_t)(itemids->values_num + 1));
trigger->itemids[0] = 0;
}
@@ -6680,7 +6686,7 @@ void DCsync_configuration(unsigned char mode)
zabbix_log(LOG_LEVEL_DEBUG, "%s() strings : %d (%d slots)", __func__,
config->strpool.num_data, config->strpool.num_slots);
- zbx_mem_dump_stats(LOG_LEVEL_DEBUG, config_mem);
+ zbx_shmem_dump_stats(LOG_LEVEL_DEBUG, config_mem);
}
out:
if (0 == sync_in_progress)
@@ -7067,13 +7073,13 @@ int init_configuration_cache(char **error)
if (SUCCEED != (ret = zbx_rwlock_create(&config_lock, ZBX_RWLOCK_CONFIG, error)))
goto out;
- if (SUCCEED != (ret = zbx_mem_create(&config_mem, CONFIG_CONF_CACHE_SIZE, "configuration cache",
+ if (SUCCEED != (ret = zbx_shmem_create(&config_mem, CONFIG_CONF_CACHE_SIZE, "configuration cache",
"CacheSize", 0, error)))
{
goto out;
}
- config = (ZBX_DC_CONFIG *)__config_mem_malloc_func(NULL, sizeof(ZBX_DC_CONFIG) +
+ config = (ZBX_DC_CONFIG *)__config_shmem_malloc_func(NULL, sizeof(ZBX_DC_CONFIG) +
CONFIG_TIMER_FORKS * sizeof(zbx_vector_ptr_t));
#define CREATE_HASHSET(hashset, hashset_size) \
@@ -7083,7 +7089,7 @@ int init_configuration_cache(char **error)
#define CREATE_HASHSET_EXT(hashset, hashset_size, hash_func, compare_func) \
\
zbx_hashset_create_ext(&hashset, hashset_size, hash_func, compare_func, NULL, \
- __config_mem_malloc_func, __config_mem_realloc_func, __config_mem_free_func)
+ __config_shmem_malloc_func, __config_shmem_realloc_func, __config_shmem_free_func)
CREATE_HASHSET(config->items, 100);
CREATE_HASHSET(config->numitems, 0);
@@ -7131,10 +7137,10 @@ int init_configuration_cache(char **error)
CREATE_HASHSET(config->corr_conditions, 0);
CREATE_HASHSET(config->corr_operations, 0);
CREATE_HASHSET(config->hostgroups, 0);
- zbx_vector_ptr_create_ext(&config->hostgroups_name, __config_mem_malloc_func, __config_mem_realloc_func,
- __config_mem_free_func);
- zbx_vector_ptr_create_ext(&config->kvs_paths, __config_mem_malloc_func, __config_mem_realloc_func,
- __config_mem_free_func);
+ zbx_vector_ptr_create_ext(&config->hostgroups_name, __config_shmem_malloc_func, __config_shmem_realloc_func,
+ __config_shmem_free_func);
+ zbx_vector_ptr_create_ext(&config->kvs_paths, __config_shmem_malloc_func, __config_shmem_realloc_func,
+ __config_shmem_free_func);
CREATE_HASHSET(config->preprocops, 0);
@@ -7165,25 +7171,25 @@ int init_configuration_cache(char **error)
zbx_binary_heap_create_ext(&config->queues[i],
__config_java_elem_compare,
ZBX_BINARY_HEAP_OPTION_DIRECT,
- __config_mem_malloc_func,
- __config_mem_realloc_func,
- __config_mem_free_func);
+ __config_shmem_malloc_func,
+ __config_shmem_realloc_func,
+ __config_shmem_free_func);
break;
case ZBX_POLLER_TYPE_PINGER:
zbx_binary_heap_create_ext(&config->queues[i],
__config_pinger_elem_compare,
ZBX_BINARY_HEAP_OPTION_DIRECT,
- __config_mem_malloc_func,
- __config_mem_realloc_func,
- __config_mem_free_func);
+ __config_shmem_malloc_func,
+ __config_shmem_realloc_func,
+ __config_shmem_free_func);
break;
default:
zbx_binary_heap_create_ext(&config->queues[i],
__config_heap_elem_compare,
ZBX_BINARY_HEAP_OPTION_DIRECT,
- __config_mem_malloc_func,
- __config_mem_realloc_func,
- __config_mem_free_func);
+ __config_shmem_malloc_func,
+ __config_shmem_realloc_func,
+ __config_shmem_free_func);
break;
}
}
@@ -7191,22 +7197,22 @@ int init_configuration_cache(char **error)
zbx_binary_heap_create_ext(&config->pqueue,
__config_proxy_compare,
ZBX_BINARY_HEAP_OPTION_DIRECT,
- __config_mem_malloc_func,
- __config_mem_realloc_func,
- __config_mem_free_func);
+ __config_shmem_malloc_func,
+ __config_shmem_realloc_func,
+ __config_shmem_free_func);
zbx_binary_heap_create_ext(&config->trigger_queue,
__config_timer_compare,
ZBX_BINARY_HEAP_OPTION_EMPTY,
- __config_mem_malloc_func,
- __config_mem_realloc_func,
- __config_mem_free_func);
+ __config_shmem_malloc_func,
+ __config_shmem_realloc_func,
+ __config_shmem_free_func);
CREATE_HASHSET_EXT(config->data_sessions, 0, __config_data_session_hash, __config_data_session_compare);
config->config = NULL;
- config->status = (ZBX_DC_STATUS *)__config_mem_malloc_func(NULL, sizeof(ZBX_DC_STATUS));
+ config->status = (ZBX_DC_STATUS *)__config_shmem_malloc_func(NULL, sizeof(ZBX_DC_STATUS));
config->status->last_update = 0;
config->availability_diff_ts = 0;
@@ -7220,8 +7226,8 @@ int init_configuration_cache(char **error)
if (0 != CONFIG_TIMER_FORKS)
{
config->maintenance_update = ZBX_MAINTENANCE_UPDATE_FALSE;
- config->maintenance_update_flags = (zbx_uint64_t *)__config_mem_malloc_func(NULL, sizeof(zbx_uint64_t) *
- ZBX_MAINTENANCE_UPDATE_FLAGS_NUM());
+ config->maintenance_update_flags = (zbx_uint64_t *)__config_shmem_malloc_func(NULL,
+ sizeof(zbx_uint64_t) * ZBX_MAINTENANCE_UPDATE_FLAGS_NUM());
memset(config->maintenance_update_flags, 0, sizeof(zbx_uint64_t) * ZBX_MAINTENANCE_UPDATE_FLAGS_NUM());
}
@@ -7262,7 +7268,7 @@ void free_configuration_cache(void)
UNLOCK_CACHE;
- zbx_mem_destroy(config_mem);
+ zbx_shmem_destroy(config_mem);
config_mem = NULL;
zbx_rwlock_destroy(&config_lock);
@@ -12708,8 +12714,8 @@ void dc_hostgroup_cache_nested_groupids(zbx_dc_hostgroup_t *parent_group)
{
int index, len;
- zbx_vector_uint64_create_ext(&parent_group->nested_groupids, __config_mem_malloc_func,
- __config_mem_realloc_func, __config_mem_free_func);
+ zbx_vector_uint64_create_ext(&parent_group->nested_groupids, __config_shmem_malloc_func,
+ __config_shmem_realloc_func, __config_shmem_free_func);
index = zbx_vector_ptr_bsearch(&config->hostgroups_name, parent_group, dc_compare_hgroups);
len = strlen(parent_group->name);
@@ -13546,16 +13552,18 @@ zbx_data_session_t *zbx_dc_get_or_create_data_session(zbx_uint64_t hostid, const
if (NULL == session)
{
+ session_local.last_valueid = 0;
+ session_local.lastaccess = now;
+ session_local.token = dc_strdup(token);
+
WRLOCK_CACHE;
+
session = (zbx_data_session_t *)zbx_hashset_insert(&config->data_sessions, &session_local,
sizeof(session_local));
- session->token = dc_strdup(token);
UNLOCK_CACHE;
-
- session->last_valueid = 0;
}
-
- session->lastaccess = now;
+ else
+ session->lastaccess = now;
return session;
}
@@ -13580,7 +13588,7 @@ void zbx_dc_cleanup_data_sessions(void)
{
if (session->lastaccess + SEC_PER_DAY <= now)
{
- __config_mem_free_func((char *)session->token);
+ __config_shmem_free_func((char *)session->token);
zbx_hashset_iter_remove(&iter);
}
}
diff --git a/src/libs/zbxdbcache/valuecache.c b/src/libs/zbxdbcache/valuecache.c
index e67eb699b51..b4fea200da6 100644
--- a/src/libs/zbxdbcache/valuecache.c
+++ b/src/libs/zbxdbcache/valuecache.c
@@ -21,7 +21,6 @@
#include "log.h"
#include "dbcache.h"
-#include "vectorimpl.h"
#include "mutexs.h"
/*
@@ -58,7 +57,7 @@
#define ZBX_VC_LOW_MEMORY_ITEM_PRINT_LIMIT 25
-static zbx_mem_info_t *vc_mem = NULL;
+static zbx_shmem_info_t *vc_mem = NULL;
zbx_rwlock_t vc_lock = ZBX_RWLOCK_NULL;
@@ -72,7 +71,7 @@ static int vc_state = ZBX_VC_DISABLED;
/* the value cache size */
extern zbx_uint64_t CONFIG_VALUE_CACHE_SIZE;
-ZBX_MEM_FUNC_IMPL(__vc, vc_mem)
+ZBX_SHMEM_FUNC_IMPL(__vc, vc_mem)
#define VC_STRPOOL_INIT_SIZE (1000)
#define VC_ITEMS_INIT_SIZE (1000)
@@ -751,7 +750,7 @@ static void vc_warn_low_memory(void)
{
vc_cache->last_warning_time = now;
vc_dump_items_statistics();
- zbx_mem_dump_stats(LOG_LEVEL_WARNING, vc_mem);
+ zbx_shmem_dump_stats(LOG_LEVEL_WARNING, vc_mem);
zabbix_log(LOG_LEVEL_WARNING, "value cache is fully used: please increase ValueCacheSize"
" configuration parameter");
@@ -953,13 +952,13 @@ static void *vc_item_malloc(zbx_vc_item_t *item, size_t size)
{
char *ptr;
- if (NULL == (ptr = (char *)__vc_mem_malloc_func(NULL, size)))
+ if (NULL == (ptr = (char *)__vc_shmem_malloc_func(NULL, size)))
{
/* If failed to allocate required memory, try to free space in */
/* cache and allocate again. If there still is not enough space - */
/* return NULL as failure. */
vc_release_space(item, size);
- ptr = (char *)__vc_mem_malloc_func(NULL, size);
+ ptr = (char *)__vc_shmem_malloc_func(NULL, size);
}
return ptr;
@@ -1091,7 +1090,7 @@ static zbx_log_value_t *vc_item_logdup(zbx_vc_item_t *item, const zbx_log_value_
fail:
vc_item_strfree(plog->source);
- __vc_mem_free_func(plog);
+ __vc_shmem_free_func(plog);
return NULL;
}
@@ -1117,7 +1116,7 @@ static size_t vc_item_logfree(zbx_log_value_t *log)
freed += vc_item_strfree(log->source);
freed += vc_item_strfree(log->value);
- __vc_mem_free_func(log);
+ __vc_shmem_free_func(log);
freed += sizeof(zbx_log_value_t);
}
@@ -1589,7 +1588,7 @@ static size_t vch_item_free_chunk(zbx_vc_item_t *item, zbx_vc_chunk_t *chunk)
freed = sizeof(zbx_vc_chunk_t) + (chunk->slots_num - 1) * sizeof(zbx_history_record_t);
freed += vc_item_free_values(item, chunk->slots, chunk->first_value, chunk->last_value);
- __vc_mem_free_func(chunk);
+ __vc_shmem_free_func(chunk);
return freed;
}
@@ -2350,14 +2349,17 @@ int zbx_vc_init(char **error)
if (SUCCEED != (ret = zbx_rwlock_create(&vc_lock, ZBX_RWLOCK_VALUECACHE, error)))
goto out;
- size_reserved = zbx_mem_required_size(1, "value cache size", "ValueCacheSize");
+ size_reserved = zbx_shmem_required_size(1, "value cache size", "ValueCacheSize");
- if (SUCCEED != zbx_mem_create(&vc_mem, CONFIG_VALUE_CACHE_SIZE, "value cache size", "ValueCacheSize", 1, error))
+ if (SUCCEED != zbx_shmem_create(&vc_mem, CONFIG_VALUE_CACHE_SIZE, "value cache size", "ValueCacheSize", 1,
+ error))
+ {
goto out;
+ }
CONFIG_VALUE_CACHE_SIZE -= size_reserved;
- vc_cache = (zbx_vc_cache_t *)__vc_mem_malloc_func(vc_cache, sizeof(zbx_vc_cache_t));
+ vc_cache = (zbx_vc_cache_t *)__vc_shmem_malloc_func(vc_cache, sizeof(zbx_vc_cache_t));
if (NULL == vc_cache)
{
@@ -2368,7 +2370,7 @@ int zbx_vc_init(char **error)
zbx_hashset_create_ext(&vc_cache->items, VC_ITEMS_INIT_SIZE,
ZBX_DEFAULT_UINT64_HASH_FUNC, ZBX_DEFAULT_UINT64_COMPARE_FUNC, NULL,
- __vc_mem_malloc_func, __vc_mem_realloc_func, __vc_mem_free_func);
+ __vc_shmem_malloc_func, __vc_shmem_realloc_func, __vc_shmem_free_func);
if (NULL == vc_cache->items.slots)
{
@@ -2378,7 +2380,7 @@ int zbx_vc_init(char **error)
zbx_hashset_create_ext(&vc_cache->strpool, VC_STRPOOL_INIT_SIZE,
vc_strpool_hash_func, vc_strpool_compare_func, NULL,
- __vc_mem_malloc_func, __vc_mem_realloc_func, __vc_mem_free_func);
+ __vc_shmem_malloc_func, __vc_shmem_realloc_func, __vc_shmem_free_func);
if (NULL == vc_cache->strpool.slots)
{
@@ -2419,10 +2421,10 @@ void zbx_vc_destroy(void)
zbx_hashset_destroy(&vc_cache->items);
zbx_hashset_destroy(&vc_cache->strpool);
- __vc_mem_free_func(vc_cache);
+ __vc_shmem_free_func(vc_cache);
vc_cache = NULL;
- zbx_mem_destroy(vc_mem);
+ zbx_shmem_destroy(vc_mem);
vc_mem = NULL;
zbx_rwlock_destroy(&vc_lock);
}
@@ -2735,16 +2737,16 @@ void zbx_vc_get_diag_stats(zbx_uint64_t *items_num, zbx_uint64_t *values_num, in
* Purpose: get value cache shared memory statistics *
* *
******************************************************************************/
-void zbx_vc_get_mem_stats(zbx_mem_stats_t *mem)
+void zbx_vc_get_mem_stats(zbx_shmem_stats_t *mem)
{
if (ZBX_VC_DISABLED == vc_state)
{
- memset(mem, 0, sizeof(zbx_mem_stats_t));
+ memset(mem, 0, sizeof(zbx_shmem_stats_t));
return;
}
RDLOCK_CACHE;
- zbx_mem_get_stats(vc_mem, mem);
+ zbx_shmem_get_stats(vc_mem, mem);
UNLOCK_CACHE;
}
diff --git a/src/libs/zbxdbcache/valuecache.h b/src/libs/zbxdbcache/valuecache.h
index 31f0975569b..3b280e5a4df 100644
--- a/src/libs/zbxdbcache/valuecache.h
+++ b/src/libs/zbxdbcache/valuecache.h
@@ -23,7 +23,7 @@
#include "zbxtypes.h"
#include "zbxalgo.h"
#include "zbxhistory.h"
-#include "memalloc.h"
+#include "zbxshmem.h"
/*
* The Value Cache provides read caching of item historical data residing in history
@@ -114,7 +114,7 @@ int zbx_vc_get_statistics(zbx_vc_stats_t *stats);
void zbx_vc_housekeeping_value_cache(void);
void zbx_vc_get_diag_stats(zbx_uint64_t *items_num, zbx_uint64_t *values_num, int *mode);
-void zbx_vc_get_mem_stats(zbx_mem_stats_t *mem);
+void zbx_vc_get_mem_stats(zbx_shmem_stats_t *mem);
void zbx_vc_get_item_stats(zbx_vector_ptr_t *stats);
void zbx_vc_flush_stats(void);
diff --git a/src/libs/zbxdbhigh/graph_linking.c b/src/libs/zbxdbhigh/graph_linking.c
index 31617627eef..15f3621678c 100644
--- a/src/libs/zbxdbhigh/graph_linking.c
+++ b/src/libs/zbxdbhigh/graph_linking.c
@@ -22,7 +22,6 @@
#include "db.h"
#include "../../libs/zbxaudit/audit.h"
#include "../../libs/zbxaudit/audit_graph.h"
-#include "../../libs/zbxalgo/vectorimpl.h"
typedef struct
{
diff --git a/src/libs/zbxdbhigh/host.c b/src/libs/zbxdbhigh/host.c
index 2f17bafaeaa..a450092b85d 100644
--- a/src/libs/zbxdbhigh/host.c
+++ b/src/libs/zbxdbhigh/host.c
@@ -29,7 +29,6 @@
#include "../../libs/zbxaudit/audit.h"
#include "trigger_linking.h"
#include "graph_linking.h"
-#include "../zbxalgo/vectorimpl.h"
#include "db.h"
diff --git a/src/libs/zbxdbhigh/tag.c b/src/libs/zbxdbhigh/tag.c
index 02e9506a461..21e4d5593b0 100644
--- a/src/libs/zbxdbhigh/tag.c
+++ b/src/libs/zbxdbhigh/tag.c
@@ -18,7 +18,6 @@
**/
#include "common.h"
-#include "../zbxalgo/vectorimpl.h"
#include "db.h"
diff --git a/src/libs/zbxdbhigh/template_item.c b/src/libs/zbxdbhigh/template_item.c
index 863dd105dc1..104f6cd1424 100644
--- a/src/libs/zbxdbhigh/template_item.c
+++ b/src/libs/zbxdbhigh/template_item.c
@@ -22,7 +22,6 @@
#include "db.h"
#include "log.h"
#include "dbcache.h"
-#include "../zbxalgo/vectorimpl.h"
#include "../../libs/zbxaudit/audit.h"
#include "../../libs/zbxaudit/audit_item.h"
diff --git a/src/libs/zbxdbhigh/trigger_dep_linking.c b/src/libs/zbxdbhigh/trigger_dep_linking.c
index 5f97a5e3bd0..6ff39733dc1 100644
--- a/src/libs/zbxdbhigh/trigger_dep_linking.c
+++ b/src/libs/zbxdbhigh/trigger_dep_linking.c
@@ -22,7 +22,6 @@
#include "db.h"
#include "log.h"
#include "../../libs/zbxaudit/audit_trigger.h"
-#include "../../libs/zbxalgo/vectorimpl.h"
typedef struct
{
diff --git a/src/libs/zbxdbhigh/trigger_linking.c b/src/libs/zbxdbhigh/trigger_linking.c
index 06526e90b33..657c22c1e51 100644
--- a/src/libs/zbxdbhigh/trigger_linking.c
+++ b/src/libs/zbxdbhigh/trigger_linking.c
@@ -24,7 +24,6 @@
#include "log.h"
#include "../../libs/zbxaudit/audit.h"
#include "../../libs/zbxaudit/audit_trigger.h"
-#include "../../libs/zbxalgo/vectorimpl.h"
#include "trigger_dep_linking.h"
typedef struct
diff --git a/src/libs/zbxdbupgrade/dbupgrade.c b/src/libs/zbxdbupgrade/dbupgrade.c
index e1a454d2d47..0d3e6977bf3 100644
--- a/src/libs/zbxdbupgrade/dbupgrade.c
+++ b/src/libs/zbxdbupgrade/dbupgrade.c
@@ -17,12 +17,11 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
+#include "zbxdbupgrade.h"
#include "dbupgrade.h"
-#include "common.h"
#include "db.h"
#include "log.h"
-#include "zbxdbupgrade.h"
typedef struct
{
diff --git a/src/libs/zbxdbupgrade/dbupgrade_2010.c b/src/libs/zbxdbupgrade/dbupgrade_2010.c
index d2374f956a1..aff08f1d997 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_2010.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_2010.c
@@ -17,9 +17,9 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
-#include "db.h"
#include "dbupgrade.h"
+
+#include "db.h"
#include "log.h"
#include "sysinfo.h"
diff --git a/src/libs/zbxdbupgrade/dbupgrade_2020.c b/src/libs/zbxdbupgrade/dbupgrade_2020.c
index 9d0a91202d9..19888a4d76d 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_2020.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_2020.c
@@ -17,7 +17,6 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
#include "dbupgrade.h"
/*
diff --git a/src/libs/zbxdbupgrade/dbupgrade_2030.c b/src/libs/zbxdbupgrade/dbupgrade_2030.c
index 769c42020eb..22a39561c2f 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_2030.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_2030.c
@@ -17,9 +17,9 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
-#include "db.h"
#include "dbupgrade.h"
+
+#include "db.h"
#include "log.h"
/*
diff --git a/src/libs/zbxdbupgrade/dbupgrade_2040.c b/src/libs/zbxdbupgrade/dbupgrade_2040.c
index 91bcaed031d..499cd005692 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_2040.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_2040.c
@@ -17,9 +17,10 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
#include "dbupgrade.h"
+#include "common.h"
+
/*
* 2.4 maintenance database patches
*/
diff --git a/src/libs/zbxdbupgrade/dbupgrade_2050.c b/src/libs/zbxdbupgrade/dbupgrade_2050.c
index 6b777c6730b..95383d0743a 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_2050.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_2050.c
@@ -17,9 +17,9 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
-#include "db.h"
#include "dbupgrade.h"
+
+#include "db.h"
#include "sysinfo.h"
#include "log.h"
diff --git a/src/libs/zbxdbupgrade/dbupgrade_3000.c b/src/libs/zbxdbupgrade/dbupgrade_3000.c
index 67885a2ea4f..2d6feb117ab 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_3000.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_3000.c
@@ -17,7 +17,6 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
#include "dbupgrade.h"
/*
diff --git a/src/libs/zbxdbupgrade/dbupgrade_3010.c b/src/libs/zbxdbupgrade/dbupgrade_3010.c
index ed304125e0e..2a2b35b935b 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_3010.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_3010.c
@@ -17,9 +17,9 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
-#include "db.h"
#include "dbupgrade.h"
+
+#include "db.h"
#include "log.h"
/*
diff --git a/src/libs/zbxdbupgrade/dbupgrade_3020.c b/src/libs/zbxdbupgrade/dbupgrade_3020.c
index 14f6b126c44..2f9f002f92d 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_3020.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_3020.c
@@ -17,10 +17,10 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
-#include "db.h"
#include "dbupgrade.h"
+#include "db.h"
+
/*
* 3.2 maintenance database patches
*/
diff --git a/src/libs/zbxdbupgrade/dbupgrade_3030.c b/src/libs/zbxdbupgrade/dbupgrade_3030.c
index 5b9e09de204..bf5e70579e2 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_3030.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_3030.c
@@ -17,9 +17,9 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
-#include "db.h"
#include "dbupgrade.h"
+
+#include "db.h"
#include "log.h"
/*
diff --git a/src/libs/zbxdbupgrade/dbupgrade_3040.c b/src/libs/zbxdbupgrade/dbupgrade_3040.c
index d0c0eabaccd..848ecb59712 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_3040.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_3040.c
@@ -17,9 +17,10 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
+#include "dbupgrade.h"
+
#include "common.h"
#include "db.h"
-#include "dbupgrade.h"
/*
* 3.4 maintenance database patches
diff --git a/src/libs/zbxdbupgrade/dbupgrade_3050.c b/src/libs/zbxdbupgrade/dbupgrade_3050.c
index cb6eae3ff51..dca7a0c57be 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_3050.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_3050.c
@@ -17,9 +17,9 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
-#include "db.h"
#include "dbupgrade.h"
+
+#include "db.h"
#include "zbxtasks.h"
#include "zbxregexp.h"
#include "log.h"
diff --git a/src/libs/zbxdbupgrade/dbupgrade_4000.c b/src/libs/zbxdbupgrade/dbupgrade_4000.c
index e7bd6d2fdd9..1f1ae92c2c0 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_4000.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_4000.c
@@ -17,11 +17,11 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
-#include "db.h"
#include "dbupgrade.h"
#include "dbupgrade_macros.h"
+#include "db.h"
+
/*
* 4.0 maintenance database patches
*/
diff --git a/src/libs/zbxdbupgrade/dbupgrade_4010.c b/src/libs/zbxdbupgrade/dbupgrade_4010.c
index c426e5b75c2..f29b95270a9 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_4010.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_4010.c
@@ -17,10 +17,10 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
-#include "db.h"
#include "dbupgrade.h"
+#include "db.h"
+
extern unsigned char program_type;
/*
diff --git a/src/libs/zbxdbupgrade/dbupgrade_4020.c b/src/libs/zbxdbupgrade/dbupgrade_4020.c
index af44b3b336c..6633710350e 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_4020.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_4020.c
@@ -17,7 +17,6 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
#include "dbupgrade.h"
extern unsigned char program_type;
diff --git a/src/libs/zbxdbupgrade/dbupgrade_4030.c b/src/libs/zbxdbupgrade/dbupgrade_4030.c
index c9bce2992e4..dfa9a3f7ab4 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_4030.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_4030.c
@@ -17,10 +17,10 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
-#include "db.h"
#include "dbupgrade.h"
+#include "db.h"
+
/*
* 4.4 development database patches
*/
diff --git a/src/libs/zbxdbupgrade/dbupgrade_4040.c b/src/libs/zbxdbupgrade/dbupgrade_4040.c
index 71de56fd179..36c20e8c233 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_4040.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_4040.c
@@ -17,7 +17,6 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
#include "dbupgrade.h"
extern unsigned char program_type;
diff --git a/src/libs/zbxdbupgrade/dbupgrade_4050.c b/src/libs/zbxdbupgrade/dbupgrade_4050.c
index 9508e28cfb0..4b62ffa28be 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_4050.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_4050.c
@@ -17,12 +17,11 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
-#include "db.h"
#include "dbupgrade.h"
+
+#include "db.h"
#include "log.h"
#include "zbxalgo.h"
-#include "../zbxalgo/vectorimpl.h"
/*
* 5.0 development database patches
diff --git a/src/libs/zbxdbupgrade/dbupgrade_5000.c b/src/libs/zbxdbupgrade/dbupgrade_5000.c
index 89cfe23becb..ea4db0f7057 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_5000.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_5000.c
@@ -17,7 +17,6 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
#include "dbupgrade.h"
extern unsigned char program_type;
diff --git a/src/libs/zbxdbupgrade/dbupgrade_5010.c b/src/libs/zbxdbupgrade/dbupgrade_5010.c
index c7e8fa983f6..09d6f8b424f 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_5010.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_5010.c
@@ -17,12 +17,11 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
-#include "db.h"
#include "dbupgrade.h"
+
+#include "db.h"
#include "log.h"
#include "zbxalgo.h"
-#include "../zbxalgo/vectorimpl.h"
/*
* 5.2 development database patches
diff --git a/src/libs/zbxdbupgrade/dbupgrade_5020.c b/src/libs/zbxdbupgrade/dbupgrade_5020.c
index 6cdf43d7cd4..a488d261a4f 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_5020.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_5020.c
@@ -17,7 +17,6 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
#include "dbupgrade.h"
extern unsigned char program_type;
diff --git a/src/libs/zbxdbupgrade/dbupgrade_5030.c b/src/libs/zbxdbupgrade/dbupgrade_5030.c
index ce223e25d51..02bf8102a9c 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_5030.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_5030.c
@@ -17,16 +17,15 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
+#include "dbupgrade.h"
+#include "dbupgrade_macros.h"
+
#include "zbxeval.h"
#include "log.h"
#include "db.h"
-#include "dbupgrade.h"
-#include "dbupgrade_macros.h"
#include "zbxregexp.h"
#include "zbxalgo.h"
#include "zbxjson.h"
-#include "../zbxalgo/vectorimpl.h"
#include "sysinfo.h"
#include "zbxhash.h"
diff --git a/src/libs/zbxdbupgrade/dbupgrade_5040.c b/src/libs/zbxdbupgrade/dbupgrade_5040.c
index c9dfc5ac0a0..086603da3eb 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_5040.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_5040.c
@@ -17,7 +17,6 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
#include "dbupgrade.h"
extern unsigned char program_type;
diff --git a/src/libs/zbxdbupgrade/dbupgrade_5050.c b/src/libs/zbxdbupgrade/dbupgrade_5050.c
index 764540eabd7..1b251780111 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_5050.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_5050.c
@@ -17,12 +17,11 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "common.h"
-#include "db.h"
#include "dbupgrade.h"
#include "dbupgrade_macros.h"
+
+#include "db.h"
#include "log.h"
-#include "../zbxalgo/vectorimpl.h"
#include "zbxhash.h"
extern unsigned char program_type;
diff --git a/src/libs/zbxdbupgrade/dbupgrade_macros.c b/src/libs/zbxdbupgrade/dbupgrade_macros.c
index 30a7efae50d..5ba23ef91b1 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_macros.c
+++ b/src/libs/zbxdbupgrade/dbupgrade_macros.c
@@ -20,8 +20,6 @@
#include "dbupgrade_macros.h"
#include "db.h"
-#include "log.h"
-#include "../zbxalgo/vectorimpl.h"
/* Function argument descriptors. */
/* Used in varargs list to describe following parameter mapping to old position. */
diff --git a/src/libs/zbxdbupgrade/dbupgrade_macros.h b/src/libs/zbxdbupgrade/dbupgrade_macros.h
index bec9804a9ef..0626258b526 100644
--- a/src/libs/zbxdbupgrade/dbupgrade_macros.h
+++ b/src/libs/zbxdbupgrade/dbupgrade_macros.h
@@ -20,7 +20,6 @@
#ifndef ZABBIX_DBUPGRADE_MACROS_H
#define ZABBIX_DBUPGRADE_MACROS_H
-#include "common.h"
#include "zbxalgo.h"
#include "zbxdb.h"
diff --git a/src/libs/zbxdiag/diag.c b/src/libs/zbxdiag/diag.c
index 6e38031c77a..786ef67fef3 100644
--- a/src/libs/zbxdiag/diag.c
+++ b/src/libs/zbxdiag/diag.c
@@ -138,7 +138,7 @@ out:
* stats - [IN] the memory statistics *
* *
******************************************************************************/
-void diag_add_mem_stats(struct zbx_json *json, const char *name, const zbx_mem_stats_t *stats)
+void diag_add_mem_stats(struct zbx_json *json, const char *name, const zbx_shmem_stats_t *stats)
{
int i;
@@ -160,14 +160,14 @@ void diag_add_mem_stats(struct zbx_json *json, const char *name, const zbx_mem_s
zbx_json_addarray(json, "buckets");
- for (i = 0; i < MEM_BUCKET_COUNT; i++)
+ for (i = 0; i < ZBX_SHMEM_BUCKET_COUNT; i++)
{
if (0 != stats->chunks_num[i])
{
char buf[MAX_ID_LEN + 2];
- zbx_snprintf(buf, sizeof(buf), "%d%s", MEM_MIN_BUCKET_SIZE + 8 * i,
- (MEM_BUCKET_COUNT - 1 == i ? "+" : ""));
+ zbx_snprintf(buf, sizeof(buf), "%d%s", ZBX_SHMEM_MIN_BUCKET_SIZE + 8 * i,
+ (ZBX_SHMEM_BUCKET_COUNT - 1 == i ? "+" : ""));
zbx_json_addobject(json, NULL);
zbx_json_adduint64(json, buf, stats->chunks_num[i]);
zbx_json_close(json);
@@ -272,7 +272,7 @@ int diag_add_historycache_info(const struct zbx_json_parse *jp, struct zbx_json
if (0 != (fields & ZBX_DIAG_HISTORYCACHE_MEMORY))
{
- zbx_mem_stats_t data_mem, index_mem, *pdata_mem, *pindex_mem;
+ zbx_shmem_stats_t data_mem, index_mem, *pdata_mem, *pindex_mem;
pdata_mem = (0 != (fields & ZBX_DIAG_HISTORYCACHE_MEMORY_DATA) ? &data_mem : NULL);
pindex_mem = (0 != (fields & ZBX_DIAG_HISTORYCACHE_MEMORY_INDEX) ? &index_mem : NULL);
diff --git a/src/libs/zbxdiag/diag.h b/src/libs/zbxdiag/diag.h
index 791ac7c6736..09f334c8fe3 100644
--- a/src/libs/zbxdiag/diag.h
+++ b/src/libs/zbxdiag/diag.h
@@ -22,7 +22,7 @@
#include "zbxjson.h"
#include "zbxalgo.h"
-#include "memalloc.h"
+#include "zbxshmem.h"
#define ZBX_DIAG_SECTION_MAX 64
#define ZBX_DIAG_FIELD_MAX 64
@@ -75,7 +75,7 @@ void diag_map_free(zbx_diag_map_t *map);
int diag_parse_request(const struct zbx_json_parse *jp, const zbx_diag_map_t *field_map, zbx_uint64_t *field_mask,
zbx_vector_ptr_t *top_views, char **error);
-void diag_add_mem_stats(struct zbx_json *json, const char *name, const zbx_mem_stats_t *stats);
+void diag_add_mem_stats(struct zbx_json *json, const char *name, const zbx_shmem_stats_t *stats);
int diag_add_section_info(const char *section, const struct zbx_json_parse *jp, struct zbx_json *json, char **error);
diff --git a/src/libs/zbxdiag/diag_server.c b/src/libs/zbxdiag/diag_server.c
index 08b899acd98..867fe1a522a 100644
--- a/src/libs/zbxdiag/diag_server.c
+++ b/src/libs/zbxdiag/diag_server.c
@@ -127,7 +127,7 @@ static int diag_add_valuecache_info(const struct zbx_json_parse *jp, struct zbx_
if (0 != (fields & ZBX_DIAG_VALUECACHE_MEMORY))
{
- zbx_mem_stats_t mem;
+ zbx_shmem_stats_t mem;
time1 = zbx_time();
zbx_vc_get_mem_stats(&mem);
diff --git a/src/libs/zbxeval/calc.c b/src/libs/zbxeval/calc.c
index 00b9dd18304..6cf2dec8992 100644
--- a/src/libs/zbxeval/calc.c
+++ b/src/libs/zbxeval/calc.c
@@ -21,7 +21,6 @@
#include "common.h"
#include "zbxalgo.h"
-#include "../../libs/zbxalgo/vectorimpl.h"
typedef struct
{
diff --git a/src/libs/zbxeval/parse.c b/src/libs/zbxeval/parse.c
index 35fae087a63..edc55a492fc 100644
--- a/src/libs/zbxeval/parse.c
+++ b/src/libs/zbxeval/parse.c
@@ -20,8 +20,6 @@
#include "zbxeval.h"
#include "eval.h"
-#include "../zbxalgo/vectorimpl.h"
-
ZBX_VECTOR_IMPL(eval_token, zbx_eval_token_t)
static int is_whitespace(char c)
diff --git a/src/libs/zbxhistory/history.c b/src/libs/zbxhistory/history.c
index 4b364e88202..d37301c6ded 100644
--- a/src/libs/zbxhistory/history.c
+++ b/src/libs/zbxhistory/history.c
@@ -21,7 +21,6 @@
#include "common.h"
#include "log.h"
-#include "../zbxalgo/vectorimpl.h"
ZBX_VECTOR_IMPL(history_record, zbx_history_record_t)
diff --git a/src/libs/zbxjson/jsonpath.c b/src/libs/zbxjson/jsonpath.c
index 0709ebd3e36..aaf1e17c4ad 100644
--- a/src/libs/zbxjson/jsonpath.c
+++ b/src/libs/zbxjson/jsonpath.c
@@ -25,7 +25,6 @@
#include "json.h"
#include "json_parser.h"
#include "zbxvariant.h"
-#include "../zbxalgo/vectorimpl.h"
typedef struct
{
diff --git a/src/libs/zbxnix/Makefile.am b/src/libs/zbxnix/Makefile.am
index 88ccea05cbb..644ea9ab7a7 100644
--- a/src/libs/zbxnix/Makefile.am
+++ b/src/libs/zbxnix/Makefile.am
@@ -12,5 +12,6 @@ libzbxnix_a_SOURCES = \
fatal.h \
ipc.c \
pid.c \
+ pid.h \
sigcommon.h \
sighandler.c
diff --git a/src/libs/zbxnix/control.c b/src/libs/zbxnix/control.c
index 3ec54fe8197..dd21b035478 100644
--- a/src/libs/zbxnix/control.c
+++ b/src/libs/zbxnix/control.c
@@ -17,6 +17,7 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
+#include "zbxnix.h"
#include "control.h"
#include "common.h"
@@ -121,7 +122,7 @@ static int parse_log_level_options(const char *opt, size_t len, unsigned int *sc
* FAIL - an error occurred *
* *
******************************************************************************/
-int parse_rtc_options(const char *opt, int *message)
+int zbx_parse_rtc_options(const char *opt, int *message)
{
unsigned int scope, data, command;
diff --git a/src/libs/zbxnix/control.h b/src/libs/zbxnix/control.h
index 534297c8fb4..456629af1af 100644
--- a/src/libs/zbxnix/control.h
+++ b/src/libs/zbxnix/control.h
@@ -24,6 +24,4 @@
#define ZBX_RTC_LOG_SCOPE_PROC 0
#define ZBX_RTC_LOG_SCOPE_PID 1
-int parse_rtc_options(const char *opt, int *message);
-
-#endif
+#endif /* ZABBIX_CONTROL_H */
diff --git a/src/libs/zbxnix/coredump.c b/src/libs/zbxnix/coredump.c
index d1fab9282cd..a55c9c58acf 100644
--- a/src/libs/zbxnix/coredump.c
+++ b/src/libs/zbxnix/coredump.c
@@ -17,9 +17,10 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
+#include "zbxnix.h"
+
#include "common.h"
#include "log.h"
-#include "zbxnix.h"
#if defined(HAVE_GNUTLS) || defined(HAVE_OPENSSL)
/******************************************************************************
diff --git a/src/libs/zbxnix/daemon.c b/src/libs/zbxnix/daemon.c
index eede4b3d59e..236ee74736e 100644
--- a/src/libs/zbxnix/daemon.c
+++ b/src/libs/zbxnix/daemon.c
@@ -17,17 +17,16 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "daemon.h"
+#include "zbxnix.h"
+
+#include "fatal.h"
+#include "sigcommon.h"
#include "common.h"
-#include "pid.h"
#include "cfg.h"
#include "log.h"
#include "control.h"
-
-#include "fatal.h"
-#include "sighandler.h"
-#include "sigcommon.h"
+#include "pid.h"
#if defined(__linux__)
#define ZBX_PID_FILE_TIMEOUT 20
@@ -322,7 +321,7 @@ static void set_daemon_signal_handlers(void)
* Comments: it doesn't allow running under 'root' if allow_root is zero *
* *
******************************************************************************/
-int daemon_start(int allow_root, const char *user, unsigned int flags)
+int zbx_daemon_start(int allow_root, const char *user, unsigned int flags)
{
struct passwd *pwd;
@@ -421,7 +420,7 @@ int daemon_start(int allow_root, const char *user, unsigned int flags)
if (FAIL == create_pid_file(CONFIG_PID_FILE))
exit(EXIT_FAILURE);
- atexit(daemon_stop);
+ atexit(zbx_daemon_stop);
parent_pid = (int)getpid();
@@ -436,7 +435,7 @@ int daemon_start(int allow_root, const char *user, unsigned int flags)
return MAIN_ZABBIX_ENTRY(flags);
}
-void daemon_stop(void)
+void zbx_daemon_stop(void)
{
/* this function is registered using atexit() to be called when we terminate */
/* there should be nothing like logging or calls to exit() beyond this point */
diff --git a/src/libs/zbxnix/dshm.c b/src/libs/zbxnix/dshm.c
index deb7893c8c9..ffab09967fb 100644
--- a/src/libs/zbxnix/dshm.c
+++ b/src/libs/zbxnix/dshm.c
@@ -17,8 +17,9 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
+#include "zbxnix.h"
+
#include "common.h"
-#include "ipc.h"
#include "log.h"
extern char *CONFIG_FILE;
diff --git a/src/libs/zbxnix/fatal.h b/src/libs/zbxnix/fatal.h
index 0ef1f02972e..78d882298b1 100644
--- a/src/libs/zbxnix/fatal.h
+++ b/src/libs/zbxnix/fatal.h
@@ -26,6 +26,6 @@
#define ZBX_FATAL_LOG_FULL_INFO (ZBX_FATAL_LOG_PC_REG_SF | ZBX_FATAL_LOG_BACKTRACE | ZBX_FATAL_LOG_MEM_MAP)
const char *get_signal_name(int sig);
-void zbx_log_fatal_info(void *context, unsigned int flags);
+void zbx_log_fatal_info(void *context, unsigned int flags);
-#endif
+#endif /* ZABBIX_FATAL_H */
diff --git a/src/libs/zbxnix/ipc.c b/src/libs/zbxnix/ipc.c
index 2b35b974e51..2899322c935 100644
--- a/src/libs/zbxnix/ipc.c
+++ b/src/libs/zbxnix/ipc.c
@@ -17,7 +17,7 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "ipc.h"
+#include "zbxnix.h"
#include "common.h"
#include "log.h"
diff --git a/src/libs/zbxnix/pid.c b/src/libs/zbxnix/pid.c
index 6ff7d180363..20d1be0fe21 100644
--- a/src/libs/zbxnix/pid.c
+++ b/src/libs/zbxnix/pid.c
@@ -17,10 +17,12 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
+#include "zbxnix.h"
#include "pid.h"
#include "common.h"
#include "log.h"
+
static FILE *fpid = NULL;
static int fdpid = -1;
diff --git a/src/libs/zbxnix/pid.h b/src/libs/zbxnix/pid.h
new file mode 100644
index 00000000000..d501d6d39cf
--- /dev/null
+++ b/src/libs/zbxnix/pid.h
@@ -0,0 +1,34 @@
+/*
+** Zabbix
+** Copyright (C) 2001-2022 Zabbix SIA
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** 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 General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+**/
+
+#ifndef ZABBIX_PID_H
+#define ZABBIX_PID_H
+
+#include "sysinc.h"
+
+#ifdef _WINDOWS
+# error "This module allowed only for Unix OS"
+#endif
+
+#include "threads.h"
+
+int create_pid_file(const char *pidfile);
+int read_pid_file(const char *pidfile, pid_t *pid, char *error, size_t max_error_len);
+void drop_pid_file(const char *pidfile);
+#endif /* ZABBIX_PID_H */
diff --git a/src/libs/zbxnix/sighandler.c b/src/libs/zbxnix/sighandler.c
index 29f579a2cb2..458e2e7d6ee 100644
--- a/src/libs/zbxnix/sighandler.c
+++ b/src/libs/zbxnix/sighandler.c
@@ -17,14 +17,13 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "sighandler.h"
+#include "zbxnix.h"
+#include "sigcommon.h"
#include "common.h"
#include "log.h"
#include "fatal.h"
-#include "sigcommon.h"
#include "zbxcrypto.h"
-#include "daemon.h"
int sig_parent_pid = -1;
volatile sig_atomic_t sig_exiting;
diff --git a/src/libs/zbxrtc/rtc_service.c b/src/libs/zbxrtc/rtc_service.c
index fdd0b7bd560..13781111576 100644
--- a/src/libs/zbxrtc/rtc_service.c
+++ b/src/libs/zbxrtc/rtc_service.c
@@ -17,14 +17,14 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "zbxserialize.h"
-#include "zbxjson.h"
-#include "daemon.h"
#include "zbxrtc.h"
#include "rtc.h"
+
+#include "zbxserialize.h"
+#include "zbxjson.h"
+#include "zbxnix.h"
#include "log.h"
#include "zbxdiag.h"
-#include "../../libs/zbxalgo/vectorimpl.h"
ZBX_PTR_VECTOR_IMPL(rtc_sub, zbx_rtc_sub_t *)
ZBX_PTR_VECTOR_IMPL(rtc_hook, zbx_rtc_hook_t *)
diff --git a/src/libs/zbxself/selfmon.c b/src/libs/zbxself/selfmon.c
index 8c298bfd040..ff759582b3b 100644
--- a/src/libs/zbxself/selfmon.c
+++ b/src/libs/zbxself/selfmon.c
@@ -24,7 +24,7 @@
#ifndef _WINDOWS
# include "mutexs.h"
-# include "ipc.h"
+# include "zbxnix.h"
# include "log.h"
# define MAX_HISTORY 60
diff --git a/src/libs/zbxserver/anomalystl.c b/src/libs/zbxserver/anomalystl.c
index 6038caf9fcd..2d2ec774b94 100644
--- a/src/libs/zbxserver/anomalystl.c
+++ b/src/libs/zbxserver/anomalystl.c
@@ -22,7 +22,6 @@
#include "common.h"
#include "log.h"
#include "zbxeval.h"
-#include "../zbxalgo/vectorimpl.h"
ZBX_PTR_VECTOR_DECL(VV, zbx_vector_history_record_t *)
ZBX_PTR_VECTOR_IMPL(VV, zbx_vector_history_record_t *)
diff --git a/src/libs/zbxserver/evalfunc.c b/src/libs/zbxserver/evalfunc.c
index 290bad8d960..8ef78f3d93b 100644
--- a/src/libs/zbxserver/evalfunc.c
+++ b/src/libs/zbxserver/evalfunc.c
@@ -24,7 +24,6 @@
#include "zbxregexp.h"
#include "valuecache.h"
#include "zbxtrends.h"
-#include "../zbxalgo/vectorimpl.h"
#include "anomalystl.h"
#include "evalfunc_common.h"
@@ -390,8 +389,8 @@ static int evaluate_value_by_map(char *value, size_t max_len, zbx_vector_valuema
{
double num1, num2;
- if (ZBX_INFINITY != (num1 = evaluate_string_to_double(value)) &&
- ZBX_INFINITY != (num2 = evaluate_string_to_double(valuemap->value)) &&
+ if (ZBX_INFINITY != (num1 = zbx_evaluate_string_to_double(value)) &&
+ ZBX_INFINITY != (num2 = zbx_evaluate_string_to_double(valuemap->value)) &&
SUCCEED == zbx_double_compare(num1, num2))
{
goto map_value;
@@ -417,18 +416,18 @@ static int evaluate_value_by_map(char *value, size_t max_len, zbx_vector_valuema
}
if (ITEM_VALUE_TYPE_STR != value_type &&
- ZBX_INFINITY != (input_value = evaluate_string_to_double(value)))
+ ZBX_INFINITY != (input_value = zbx_evaluate_string_to_double(value)))
{
double min, max;
if (ZBX_VALUEMAP_TYPE_LESS_OR_EQUAL == valuemap->type &&
- ZBX_INFINITY != (max = evaluate_string_to_double(valuemap->value)))
+ ZBX_INFINITY != (max = zbx_evaluate_string_to_double(valuemap->value)))
{
if (input_value <= max)
goto map_value;
}
else if (ZBX_VALUEMAP_TYPE_GREATER_OR_EQUAL == valuemap->type &&
- ZBX_INFINITY != (min = evaluate_string_to_double(valuemap->value)))
+ ZBX_INFINITY != (min = zbx_evaluate_string_to_double(valuemap->value)))
{
if (input_value >= min)
goto map_value;
@@ -463,14 +462,14 @@ static int evaluate_value_by_map(char *value, size_t max_len, zbx_vector_valuema
if (NULL == ptr)
{
- min = evaluate_string_to_double(range_str);
+ min = zbx_evaluate_string_to_double(range_str);
found = ZBX_INFINITY != min && SUCCEED == zbx_double_compare(input_value, min);
}
else
{
*ptr = '\0';
- min = evaluate_string_to_double(range_str);
- max = evaluate_string_to_double(ptr + 1);
+ min = zbx_evaluate_string_to_double(range_str);
+ max = zbx_evaluate_string_to_double(ptr + 1);
if (ZBX_INFINITY != min && ZBX_INFINITY != max &&
input_value >= min && input_value <= max)
{
@@ -2623,6 +2622,7 @@ static int trends_eval_stl(const char *table, zbx_uint64_t itemid, int start, in
zbx_history_record_t val;
val.timestamp.sec = period_counter;
+ val.timestamp.ns = 0;
if (FAIL == zbx_trends_eval_avg(table, itemid, period_counter, period_counter, &tmp_res, NULL))
{
diff --git a/src/libs/zbxserver/expression.c b/src/libs/zbxserver/expression.c
index 2a6513eea72..a54e4e89cdf 100644
--- a/src/libs/zbxserver/expression.c
+++ b/src/libs/zbxserver/expression.c
@@ -27,7 +27,6 @@
#include "zbxeval.h"
#include "valuecache.h"
#include "macrofunc.h"
-#include "../zbxalgo/vectorimpl.h"
#include "zbxxml.h"
typedef struct
@@ -5292,7 +5291,7 @@ static void substitute_functions(zbx_vector_ptr_t *triggers, const zbx_vector_ui
ZBX_DEFAULT_UINT64_COMPARE_FUNC);
zbx_hashset_create_ext(&funcs, triggers->values_num, func_hash_func, func_compare_func, func_clean,
- ZBX_DEFAULT_MEM_MALLOC_FUNC, ZBX_DEFAULT_MEM_REALLOC_FUNC, ZBX_DEFAULT_MEM_FREE_FUNC);
+ ZBX_DEFAULT_MEM_MALLOC_FUNC, ZBX_DEFAULT_MEM_REALLOC_FUNC, ZBX_DEFAULT_MEM_FREE_FUNC);
zbx_populate_function_items(&functionids, &funcs, &ifuncs, triggers);
diff --git a/src/libs/zbxservice/service.c b/src/libs/zbxservice/service.c
index 0e5b3c4659d..904a94ff60d 100644
--- a/src/libs/zbxservice/service.c
+++ b/src/libs/zbxservice/service.c
@@ -21,7 +21,6 @@
#include "log.h"
#include "zbxipcservice.h"
-#include "../../libs/zbxalgo/vectorimpl.h"
ZBX_PTR_VECTOR_IMPL(service, DB_SERVICE *)
void zbx_service_flush(zbx_uint32_t code, unsigned char *data, zbx_uint32_t size)
diff --git a/src/libs/zbxmemory/Makefile.am b/src/libs/zbxshmem/Makefile.am
index 7dcd4dbfbbd..1694e7e8132 100644
--- a/src/libs/zbxmemory/Makefile.am
+++ b/src/libs/zbxshmem/Makefile.am
@@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in
-noinst_LIBRARIES = libzbxmemory.a
+noinst_LIBRARIES = libzbxshmem.a
-libzbxmemory_a_SOURCES = \
+libzbxshmem_a_SOURCES = \
memalloc.c
diff --git a/src/libs/zbxmemory/memalloc.c b/src/libs/zbxshmem/memalloc.c
index 080be17efd6..d181b71d3e3 100644
--- a/src/libs/zbxmemory/memalloc.c
+++ b/src/libs/zbxshmem/memalloc.c
@@ -17,7 +17,7 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "memalloc.h"
+#include "zbxshmem.h"
#include "common.h"
#include "log.h"
@@ -44,7 +44,7 @@
* *
* 8-aligned 8-aligned *
* *
- * when a chunk is used, `size' fields have MEM_FLG_USED bit set *
+ * when a chunk is used, `size' fields have SHMEM_FLG_USED bit set *
* *
* when a chunk is free, the first 2 * ZBX_PTR_SIZE bytes of allocatable *
* memory contain pointers to the previous and next chunks, in that order *
@@ -55,7 +55,7 @@
* *
* - size is kept on both left and right ends for quick merging *
* (when freeing a chunk, we can quickly see if the previous *
- * and next chunks are free, those will not have MEM_FLG_USED) *
+ * and next chunks are free, those will not have SHMEM_FLG_USED) *
* *
* (*) free chunks are stored in doubly-linked lists according to their sizes *
* *
@@ -80,7 +80,7 @@
* | | *
* *
* lo_bound `size' fields in chunk B hi_bound *
- * (aligned) have MEM_FLG_USED bit set (aligned) *
+ * (aligned) have SHMEM_FLG_USED bit set (aligned) *
* *
******************************************************************************/
@@ -101,22 +101,22 @@ static void mem_set_next_chunk(void *chunk, void *next);
static void **mem_ptr_to_prev_field(void *chunk);
static void **mem_ptr_to_next_field(void *chunk, void **first_chunk);
-static void mem_link_chunk(zbx_mem_info_t *info, void *chunk);
-static void mem_unlink_chunk(zbx_mem_info_t *info, void *chunk);
+static void mem_link_chunk(zbx_shmem_info_t *info, void *chunk);
+static void mem_unlink_chunk(zbx_shmem_info_t *info, void *chunk);
-static void *__mem_malloc(zbx_mem_info_t *info, zbx_uint64_t size);
-static void *__mem_realloc(zbx_mem_info_t *info, void *old, zbx_uint64_t size);
-static void __mem_free(zbx_mem_info_t *info, void *ptr);
+static void *__mem_malloc(zbx_shmem_info_t *info, zbx_uint64_t size);
+static void *__mem_realloc(zbx_shmem_info_t *info, void *old, zbx_uint64_t size);
+static void __mem_free(zbx_shmem_info_t *info, void *ptr);
-#define MEM_SIZE_FIELD sizeof(zbx_uint64_t)
+#define SHMEM_SIZE_FIELD sizeof(zbx_uint64_t)
-#define MEM_FLG_USED ((__UINT64_C(1))<<63)
+#define SHMEM_FLG_USED ((__UINT64_C(1))<<63)
-#define FREE_CHUNK(ptr) (((*(zbx_uint64_t *)(ptr)) & MEM_FLG_USED) == 0)
-#define CHUNK_SIZE(ptr) ((*(zbx_uint64_t *)(ptr)) & ~MEM_FLG_USED)
+#define FREE_CHUNK(ptr) (((*(zbx_uint64_t *)(ptr)) & SHMEM_FLG_USED) == 0)
+#define CHUNK_SIZE(ptr) ((*(zbx_uint64_t *)(ptr)) & ~SHMEM_FLG_USED)
-#define MEM_MIN_SIZE __UINT64_C(128)
-#define MEM_MAX_SIZE __UINT64_C(0x1000000000) /* 64 GB */
+#define SHMEM_MIN_SIZE __UINT64_C(128)
+#define SHMEM_MAX_SIZE __UINT64_C(0x1000000000) /* 64 GB */
/* helper functions */
@@ -141,64 +141,64 @@ static void *ALIGNPTR(void *ptr)
static zbx_uint64_t mem_proper_alloc_size(zbx_uint64_t size)
{
- if (size >= MEM_MIN_ALLOC)
+ if (size >= SHMEM_MIN_ALLOC)
return size + ((8 - (size & 7)) & 7); /* allocate in multiples of 8... */
else
- return MEM_MIN_ALLOC; /* ...and at least MEM_MIN_ALLOC */
+ return SHMEM_MIN_ALLOC; /* ...and at least SHMEM_MIN_ALLOC */
}
static int mem_bucket_by_size(zbx_uint64_t size)
{
- if (size < MEM_MIN_BUCKET_SIZE)
+ if (size < ZBX_SHMEM_MIN_BUCKET_SIZE)
return 0;
- if (size < MEM_MAX_BUCKET_SIZE)
- return (size - MEM_MIN_BUCKET_SIZE) >> 3;
- return MEM_BUCKET_COUNT - 1;
+ if (size < SHMEM_MAX_BUCKET_SIZE)
+ return (size - ZBX_SHMEM_MIN_BUCKET_SIZE) >> 3;
+ return ZBX_SHMEM_BUCKET_COUNT - 1;
}
static void mem_set_chunk_size(void *chunk, zbx_uint64_t size)
{
*(zbx_uint64_t *)chunk = size;
- *(zbx_uint64_t *)((char *)chunk + MEM_SIZE_FIELD + size) = size;
+ *(zbx_uint64_t *)((char *)chunk + SHMEM_SIZE_FIELD + size) = size;
}
static void mem_set_used_chunk_size(void *chunk, zbx_uint64_t size)
{
- *(zbx_uint64_t *)chunk = MEM_FLG_USED | size;
- *(zbx_uint64_t *)((char *)chunk + MEM_SIZE_FIELD + size) = MEM_FLG_USED | size;
+ *(zbx_uint64_t *)chunk = SHMEM_FLG_USED | size;
+ *(zbx_uint64_t *)((char *)chunk + SHMEM_SIZE_FIELD + size) = SHMEM_FLG_USED | size;
}
static void *mem_get_prev_chunk(void *chunk)
{
- return *(void **)((char *)chunk + MEM_SIZE_FIELD);
+ return *(void **)((char *)chunk + SHMEM_SIZE_FIELD);
}
static void mem_set_prev_chunk(void *chunk, void *prev)
{
- *(void **)((char *)chunk + MEM_SIZE_FIELD) = prev;
+ *(void **)((char *)chunk + SHMEM_SIZE_FIELD) = prev;
}
static void *mem_get_next_chunk(void *chunk)
{
- return *(void **)((char *)chunk + MEM_SIZE_FIELD + ZBX_PTR_SIZE);
+ return *(void **)((char *)chunk + SHMEM_SIZE_FIELD + ZBX_PTR_SIZE);
}
static void mem_set_next_chunk(void *chunk, void *next)
{
- *(void **)((char *)chunk + MEM_SIZE_FIELD + ZBX_PTR_SIZE) = next;
+ *(void **)((char *)chunk + SHMEM_SIZE_FIELD + ZBX_PTR_SIZE) = next;
}
static void **mem_ptr_to_prev_field(void *chunk)
{
- return (NULL != chunk ? (void **)((char *)chunk + MEM_SIZE_FIELD) : NULL);
+ return (NULL != chunk ? (void **)((char *)chunk + SHMEM_SIZE_FIELD) : NULL);
}
static void **mem_ptr_to_next_field(void *chunk, void **first_chunk)
{
- return (NULL != chunk ? (void **)((char *)chunk + MEM_SIZE_FIELD + ZBX_PTR_SIZE) : first_chunk);
+ return (NULL != chunk ? (void **)((char *)chunk + SHMEM_SIZE_FIELD + ZBX_PTR_SIZE) : first_chunk);
}
-static void mem_link_chunk(zbx_mem_info_t *info, void *chunk)
+static void mem_link_chunk(zbx_shmem_info_t *info, void *chunk)
{
int index;
@@ -213,7 +213,7 @@ static void mem_link_chunk(zbx_mem_info_t *info, void *chunk)
info->buckets[index] = chunk;
}
-static void mem_unlink_chunk(zbx_mem_info_t *info, void *chunk)
+static void mem_unlink_chunk(zbx_shmem_info_t *info, void *chunk)
{
int index;
void *prev_chunk, *next_chunk;
@@ -234,7 +234,7 @@ static void mem_unlink_chunk(zbx_mem_info_t *info, void *chunk)
/* private memory functions */
-static void *__mem_malloc(zbx_mem_info_t *info, zbx_uint64_t size)
+static void *__mem_malloc(zbx_shmem_info_t *info, zbx_uint64_t size)
{
int index;
void *chunk;
@@ -246,12 +246,12 @@ static void *__mem_malloc(zbx_mem_info_t *info, zbx_uint64_t size)
index = mem_bucket_by_size(size);
- while (index < MEM_BUCKET_COUNT - 1 && NULL == info->buckets[index])
+ while (index < ZBX_SHMEM_BUCKET_COUNT - 1 && NULL == info->buckets[index])
index++;
chunk = info->buckets[index];
- if (index == MEM_BUCKET_COUNT - 1)
+ if (index == ZBX_SHMEM_BUCKET_COUNT - 1)
{
/* otherwise, find a chunk big enough according to first-fit strategy */
@@ -292,7 +292,7 @@ static void *__mem_malloc(zbx_mem_info_t *info, zbx_uint64_t size)
/* either use the full chunk or split it */
- if (chunk_size < size + 2 * MEM_SIZE_FIELD + MEM_MIN_ALLOC)
+ if (chunk_size < size + 2 * SHMEM_SIZE_FIELD + SHMEM_MIN_ALLOC)
{
info->used_size += chunk_size;
info->free_size -= chunk_size;
@@ -304,8 +304,8 @@ static void *__mem_malloc(zbx_mem_info_t *info, zbx_uint64_t size)
void *new_chunk;
zbx_uint64_t new_chunk_size;
- new_chunk = (void *)((char *)chunk + MEM_SIZE_FIELD + size + MEM_SIZE_FIELD);
- new_chunk_size = chunk_size - size - 2 * MEM_SIZE_FIELD;
+ new_chunk = (void *)((char *)chunk + SHMEM_SIZE_FIELD + size + SHMEM_SIZE_FIELD);
+ new_chunk_size = chunk_size - size - 2 * SHMEM_SIZE_FIELD;
mem_set_chunk_size(new_chunk, new_chunk_size);
mem_link_chunk(info, new_chunk);
@@ -319,7 +319,7 @@ static void *__mem_malloc(zbx_mem_info_t *info, zbx_uint64_t size)
return chunk;
}
-static void *__mem_realloc(zbx_mem_info_t *info, void *old, zbx_uint64_t size)
+static void *__mem_realloc(zbx_shmem_info_t *info, void *old, zbx_uint64_t size)
{
void *chunk, *new_chunk, *next_chunk;
zbx_uint64_t chunk_size, new_chunk_size;
@@ -327,10 +327,10 @@ static void *__mem_realloc(zbx_mem_info_t *info, void *old, zbx_uint64_t size)
size = mem_proper_alloc_size(size);
- chunk = (void *)((char *)old - MEM_SIZE_FIELD);
+ chunk = (void *)((char *)old - SHMEM_SIZE_FIELD);
chunk_size = CHUNK_SIZE(chunk);
- next_chunk = (void *)((char *)chunk + MEM_SIZE_FIELD + chunk_size + MEM_SIZE_FIELD);
+ next_chunk = (void *)((char *)chunk + SHMEM_SIZE_FIELD + chunk_size + SHMEM_SIZE_FIELD);
next_free = (next_chunk < info->hi_bound && FREE_CHUNK(next_chunk));
if (size <= chunk_size)
@@ -347,7 +347,7 @@ static void *__mem_realloc(zbx_mem_info_t *info, void *old, zbx_uint64_t size)
info->used_size -= chunk_size - size;
info->free_size += chunk_size - size;
- new_chunk = (void *)((char *)chunk + MEM_SIZE_FIELD + size + MEM_SIZE_FIELD);
+ new_chunk = (void *)((char *)chunk + SHMEM_SIZE_FIELD + size + SHMEM_SIZE_FIELD);
new_chunk_size = CHUNK_SIZE(next_chunk) + (chunk_size - size);
mem_unlink_chunk(info, next_chunk);
@@ -362,10 +362,10 @@ static void *__mem_realloc(zbx_mem_info_t *info, void *old, zbx_uint64_t size)
/* split the current one */
info->used_size -= chunk_size - size;
- info->free_size += chunk_size - size - 2 * MEM_SIZE_FIELD;
+ info->free_size += chunk_size - size - 2 * SHMEM_SIZE_FIELD;
- new_chunk = (void *)((char *)chunk + MEM_SIZE_FIELD + size + MEM_SIZE_FIELD);
- new_chunk_size = chunk_size - size - 2 * MEM_SIZE_FIELD;
+ new_chunk = (void *)((char *)chunk + SHMEM_SIZE_FIELD + size + SHMEM_SIZE_FIELD);
+ new_chunk_size = chunk_size - size - 2 * SHMEM_SIZE_FIELD;
mem_set_chunk_size(new_chunk, new_chunk_size);
mem_link_chunk(info, new_chunk);
@@ -376,18 +376,18 @@ static void *__mem_realloc(zbx_mem_info_t *info, void *old, zbx_uint64_t size)
return chunk;
}
- if (next_free && chunk_size + 2 * MEM_SIZE_FIELD + CHUNK_SIZE(next_chunk) >= size)
+ if (next_free && chunk_size + 2 * SHMEM_SIZE_FIELD + CHUNK_SIZE(next_chunk) >= size)
{
info->used_size -= chunk_size;
- info->free_size += chunk_size + 2 * MEM_SIZE_FIELD;
+ info->free_size += chunk_size + 2 * SHMEM_SIZE_FIELD;
- chunk_size += 2 * MEM_SIZE_FIELD + CHUNK_SIZE(next_chunk);
+ chunk_size += 2 * SHMEM_SIZE_FIELD + CHUNK_SIZE(next_chunk);
mem_unlink_chunk(info, next_chunk);
/* either use the full next_chunk or split it */
- if (chunk_size < size + 2 * MEM_SIZE_FIELD + MEM_MIN_ALLOC)
+ if (chunk_size < size + 2 * SHMEM_SIZE_FIELD + SHMEM_MIN_ALLOC)
{
info->used_size += chunk_size;
info->free_size -= chunk_size;
@@ -396,8 +396,8 @@ static void *__mem_realloc(zbx_mem_info_t *info, void *old, zbx_uint64_t size)
}
else
{
- new_chunk = (void *)((char *)chunk + MEM_SIZE_FIELD + size + MEM_SIZE_FIELD);
- new_chunk_size = chunk_size - size - 2 * MEM_SIZE_FIELD;
+ new_chunk = (void *)((char *)chunk + SHMEM_SIZE_FIELD + size + SHMEM_SIZE_FIELD);
+ new_chunk_size = chunk_size - size - 2 * SHMEM_SIZE_FIELD;
mem_set_chunk_size(new_chunk, new_chunk_size);
mem_link_chunk(info, new_chunk);
@@ -412,7 +412,7 @@ static void *__mem_realloc(zbx_mem_info_t *info, void *old, zbx_uint64_t size)
}
else if (NULL != (new_chunk = __mem_malloc(info, size)))
{
- memcpy((char *)new_chunk + MEM_SIZE_FIELD, (char *)chunk + MEM_SIZE_FIELD, chunk_size);
+ memcpy((char *)new_chunk + SHMEM_SIZE_FIELD, (char *)chunk + SHMEM_SIZE_FIELD, chunk_size);
__mem_free(info, old);
@@ -427,17 +427,17 @@ static void *__mem_realloc(zbx_mem_info_t *info, void *old, zbx_uint64_t size)
new_chunk_size = chunk_size;
if (0 != next_free)
- new_chunk_size += CHUNK_SIZE(next_chunk) + 2 * MEM_SIZE_FIELD;
+ new_chunk_size += CHUNK_SIZE(next_chunk) + 2 * SHMEM_SIZE_FIELD;
- if (info->lo_bound < chunk && FREE_CHUNK((char *)chunk - MEM_SIZE_FIELD))
- new_chunk_size += CHUNK_SIZE((char *)chunk - MEM_SIZE_FIELD) + 2 * MEM_SIZE_FIELD;
+ if (info->lo_bound < chunk && FREE_CHUNK((char *)chunk - SHMEM_SIZE_FIELD))
+ new_chunk_size += CHUNK_SIZE((char *)chunk - SHMEM_SIZE_FIELD) + 2 * SHMEM_SIZE_FIELD;
if (size > new_chunk_size)
return NULL;
tmp = zbx_malloc(tmp, chunk_size);
- memcpy(tmp, (char *)chunk + MEM_SIZE_FIELD, chunk_size);
+ memcpy(tmp, (char *)chunk + SHMEM_SIZE_FIELD, chunk_size);
__mem_free(info, old);
@@ -447,7 +447,7 @@ static void *__mem_realloc(zbx_mem_info_t *info, void *old, zbx_uint64_t size)
exit(EXIT_FAILURE);
}
- memcpy((char *)new_chunk + MEM_SIZE_FIELD, tmp, chunk_size);
+ memcpy((char *)new_chunk + SHMEM_SIZE_FIELD, tmp, chunk_size);
zbx_free(tmp);
@@ -455,14 +455,14 @@ static void *__mem_realloc(zbx_mem_info_t *info, void *old, zbx_uint64_t size)
}
}
-static void __mem_free(zbx_mem_info_t *info, void *ptr)
+static void __mem_free(zbx_shmem_info_t *info, void *ptr)
{
void *chunk;
void *prev_chunk, *next_chunk;
zbx_uint64_t chunk_size;
int prev_free, next_free;
- chunk = (void *)((char *)ptr - MEM_SIZE_FIELD);
+ chunk = (void *)((char *)ptr - SHMEM_SIZE_FIELD);
chunk_size = CHUNK_SIZE(chunk);
info->used_size -= chunk_size;
@@ -470,19 +470,19 @@ static void __mem_free(zbx_mem_info_t *info, void *ptr)
/* see if we can merge with previous and next chunks */
- next_chunk = (void *)((char *)chunk + MEM_SIZE_FIELD + chunk_size + MEM_SIZE_FIELD);
+ next_chunk = (void *)((char *)chunk + SHMEM_SIZE_FIELD + chunk_size + SHMEM_SIZE_FIELD);
- prev_free = (info->lo_bound < chunk && FREE_CHUNK((char *)chunk - MEM_SIZE_FIELD));
+ prev_free = (info->lo_bound < chunk && FREE_CHUNK((char *)chunk - SHMEM_SIZE_FIELD));
next_free = (next_chunk < info->hi_bound && FREE_CHUNK(next_chunk));
if (prev_free && next_free)
{
- info->free_size += 4 * MEM_SIZE_FIELD;
+ info->free_size += 4 * SHMEM_SIZE_FIELD;
- prev_chunk = (char *)chunk - MEM_SIZE_FIELD - CHUNK_SIZE((char *)chunk - MEM_SIZE_FIELD) -
- MEM_SIZE_FIELD;
+ prev_chunk = (char *)chunk - SHMEM_SIZE_FIELD - CHUNK_SIZE((char *)chunk - SHMEM_SIZE_FIELD) -
+ SHMEM_SIZE_FIELD;
- chunk_size += 4 * MEM_SIZE_FIELD + CHUNK_SIZE(prev_chunk) + CHUNK_SIZE(next_chunk);
+ chunk_size += 4 * SHMEM_SIZE_FIELD + CHUNK_SIZE(prev_chunk) + CHUNK_SIZE(next_chunk);
mem_unlink_chunk(info, prev_chunk);
mem_unlink_chunk(info, next_chunk);
@@ -493,12 +493,12 @@ static void __mem_free(zbx_mem_info_t *info, void *ptr)
}
else if (prev_free)
{
- info->free_size += 2 * MEM_SIZE_FIELD;
+ info->free_size += 2 * SHMEM_SIZE_FIELD;
- prev_chunk = (void *)((char *)chunk - MEM_SIZE_FIELD - CHUNK_SIZE((char *)chunk - MEM_SIZE_FIELD) -
- MEM_SIZE_FIELD);
+ prev_chunk = (void *)((char *)chunk - SHMEM_SIZE_FIELD - CHUNK_SIZE((char *)chunk - SHMEM_SIZE_FIELD) -
+ SHMEM_SIZE_FIELD);
- chunk_size += 2 * MEM_SIZE_FIELD + CHUNK_SIZE(prev_chunk);
+ chunk_size += 2 * SHMEM_SIZE_FIELD + CHUNK_SIZE(prev_chunk);
mem_unlink_chunk(info, prev_chunk);
@@ -508,9 +508,9 @@ static void __mem_free(zbx_mem_info_t *info, void *ptr)
}
else if (next_free)
{
- info->free_size += 2 * MEM_SIZE_FIELD;
+ info->free_size += 2 * SHMEM_SIZE_FIELD;
- chunk_size += 2 * MEM_SIZE_FIELD + CHUNK_SIZE(next_chunk);
+ chunk_size += 2 * SHMEM_SIZE_FIELD + CHUNK_SIZE(next_chunk);
mem_unlink_chunk(info, next_chunk);
@@ -526,8 +526,8 @@ static void __mem_free(zbx_mem_info_t *info, void *ptr)
/* public memory interface */
-int zbx_mem_create(zbx_mem_info_t **info, zbx_uint64_t size, const char *descr, const char *param, int allow_oom,
- char **error)
+int zbx_shmem_create(zbx_shmem_info_t **info, zbx_uint64_t size, const char *descr, const char *param,
+ int allow_oom, char **error)
{
int shm_id, index, ret = FAIL;
void *base;
@@ -546,10 +546,10 @@ int zbx_mem_create(zbx_mem_info_t **info, zbx_uint64_t size, const char *descr,
goto out;
}
- if (!(MEM_MIN_SIZE <= size && size <= MEM_MAX_SIZE))
+ if (!(SHMEM_MIN_SIZE <= size && size <= SHMEM_MAX_SIZE))
{
*error = zbx_dsprintf(*error, "requested size " ZBX_FS_SIZE_T " not within bounds [" ZBX_FS_UI64
- " <= size <= " ZBX_FS_UI64 "]", (zbx_fs_size_t)size, MEM_MIN_SIZE, MEM_MAX_SIZE);
+ " <= size <= " ZBX_FS_UI64 "]", (zbx_fs_size_t)size, SHMEM_MIN_SIZE, SHMEM_MAX_SIZE);
goto out;
}
@@ -571,9 +571,9 @@ int zbx_mem_create(zbx_mem_info_t **info, zbx_uint64_t size, const char *descr,
ret = SUCCEED;
- /* allocate zbx_mem_info_t structure, its buckets, and description inside shared memory */
+ /* allocate zbx_shmem_info_t structure, its buckets, and description inside shared memory */
- *info = (zbx_mem_info_t *)ALIGN8(base);
+ *info = (zbx_shmem_info_t *)ALIGN8(base);
(*info)->base = base;
(*info)->shm_id = shm_id;
(*info)->orig_size = size;
@@ -582,9 +582,9 @@ int zbx_mem_create(zbx_mem_info_t **info, zbx_uint64_t size, const char *descr,
base = (void *)(*info + 1);
(*info)->buckets = (void **)ALIGNPTR(base);
- memset((*info)->buckets, 0, MEM_BUCKET_COUNT * ZBX_PTR_SIZE);
- size -= (char *)((*info)->buckets + MEM_BUCKET_COUNT) - (char *)base;
- base = (void *)((*info)->buckets + MEM_BUCKET_COUNT);
+ memset((*info)->buckets, 0, ZBX_SHMEM_BUCKET_COUNT * ZBX_PTR_SIZE);
+ size -= (char *)((*info)->buckets + ZBX_SHMEM_BUCKET_COUNT) - (char *)base;
+ base = (void *)((*info)->buckets + ZBX_SHMEM_BUCKET_COUNT);
zbx_strlcpy((char *)base, descr, size);
(*info)->mem_descr = (char *)base;
@@ -603,7 +603,7 @@ int zbx_mem_create(zbx_mem_info_t **info, zbx_uint64_t size, const char *descr,
(*info)->hi_bound = ALIGN8((char *)base + size - 8);
(*info)->total_size = (zbx_uint64_t)((char *)((*info)->hi_bound) - (char *)((*info)->lo_bound) -
- 2 * MEM_SIZE_FIELD);
+ 2 * SHMEM_SIZE_FIELD);
index = mem_bucket_by_size((*info)->total_size);
(*info)->buckets[index] = (*info)->lo_bound;
@@ -615,8 +615,8 @@ int zbx_mem_create(zbx_mem_info_t **info, zbx_uint64_t size, const char *descr,
(*info)->free_size = (*info)->total_size;
zabbix_log(LOG_LEVEL_DEBUG, "valid user addresses: [%p, %p] total size: " ZBX_FS_SIZE_T,
- (void *)((char *)(*info)->lo_bound + MEM_SIZE_FIELD),
- (void *)((char *)(*info)->hi_bound - MEM_SIZE_FIELD),
+ (void *)((char *)(*info)->lo_bound + SHMEM_SIZE_FIELD),
+ (void *)((char *)(*info)->hi_bound - SHMEM_SIZE_FIELD),
(zbx_fs_size_t)(*info)->total_size);
out:
zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __func__);
@@ -624,12 +624,12 @@ out:
return ret;
}
-void zbx_mem_destroy(zbx_mem_info_t *info)
+void zbx_shmem_destroy(zbx_shmem_info_t *info)
{
(void)shmdt(info->base);
}
-void *__zbx_mem_malloc(const char *file, int line, zbx_mem_info_t *info, const void *old, size_t size)
+void *__zbx_shmem_malloc(const char *file, int line, zbx_shmem_info_t *info, const void *old, size_t size)
{
void *chunk;
@@ -640,7 +640,7 @@ void *__zbx_mem_malloc(const char *file, int line, zbx_mem_info_t *info, const v
exit(EXIT_FAILURE);
}
- if (0 == size || size > MEM_MAX_SIZE)
+ if (0 == size || size > SHMEM_MAX_SIZE)
{
zabbix_log(LOG_LEVEL_CRIT, "[file:%s,line:%d] %s(): asking for a bad number of bytes (" ZBX_FS_SIZE_T
")", file, line, __func__, (zbx_fs_size_t)size);
@@ -658,19 +658,19 @@ void *__zbx_mem_malloc(const char *file, int line, zbx_mem_info_t *info, const v
file, line, __func__, (zbx_fs_size_t)size);
zabbix_log(LOG_LEVEL_CRIT, "[file:%s,line:%d] %s(): please increase %s configuration parameter",
file, line, __func__, info->mem_param);
- zbx_mem_dump_stats(LOG_LEVEL_CRIT, info);
+ zbx_shmem_dump_stats(LOG_LEVEL_CRIT, info);
zbx_backtrace();
exit(EXIT_FAILURE);
}
- return (void *)((char *)chunk + MEM_SIZE_FIELD);
+ return (void *)((char *)chunk + SHMEM_SIZE_FIELD);
}
-void *__zbx_mem_realloc(const char *file, int line, zbx_mem_info_t *info, void *old, size_t size)
+void *__zbx_shmem_realloc(const char *file, int line, zbx_shmem_info_t *info, void *old, size_t size)
{
void *chunk;
- if (0 == size || size > MEM_MAX_SIZE)
+ if (0 == size || size > SHMEM_MAX_SIZE)
{
zabbix_log(LOG_LEVEL_CRIT, "[file:%s,line:%d] %s(): asking for a bad number of bytes (" ZBX_FS_SIZE_T
")", file, line, __func__, (zbx_fs_size_t)size);
@@ -691,15 +691,15 @@ void *__zbx_mem_realloc(const char *file, int line, zbx_mem_info_t *info, void *
file, line, __func__, (zbx_fs_size_t)size);
zabbix_log(LOG_LEVEL_CRIT, "[file:%s,line:%d] %s(): please increase %s configuration parameter",
file, line, __func__, info->mem_param);
- zbx_mem_dump_stats(LOG_LEVEL_CRIT, info);
+ zbx_shmem_dump_stats(LOG_LEVEL_CRIT, info);
zbx_backtrace();
exit(EXIT_FAILURE);
}
- return (void *)((char *)chunk + MEM_SIZE_FIELD);
+ return (void *)((char *)chunk + SHMEM_SIZE_FIELD);
}
-void __zbx_mem_free(const char *file, int line, zbx_mem_info_t *info, void *ptr)
+void __zbx_shmem_free(const char *file, int line, zbx_shmem_info_t *info, void *ptr)
{
if (NULL == ptr)
{
@@ -710,13 +710,13 @@ void __zbx_mem_free(const char *file, int line, zbx_mem_info_t *info, void *ptr)
__mem_free(info, ptr);
}
-void zbx_mem_clear(zbx_mem_info_t *info)
+void zbx_shmem_clear(zbx_shmem_info_t *info)
{
int index;
zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __func__);
- memset(info->buckets, 0, MEM_BUCKET_COUNT * ZBX_PTR_SIZE);
+ memset(info->buckets, 0, ZBX_SHMEM_BUCKET_COUNT * ZBX_PTR_SIZE);
index = mem_bucket_by_size(info->total_size);
info->buckets[index] = info->lo_bound;
mem_set_chunk_size(info->buckets[index], info->total_size);
@@ -728,7 +728,7 @@ void zbx_mem_clear(zbx_mem_info_t *info)
zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __func__);
}
-void zbx_mem_get_stats(const zbx_mem_info_t *info, zbx_mem_stats_t *stats)
+void zbx_shmem_get_stats(const zbx_shmem_info_t *info, zbx_shmem_stats_t *stats)
{
void *chunk;
int i;
@@ -738,7 +738,7 @@ void zbx_mem_get_stats(const zbx_mem_info_t *info, zbx_mem_stats_t *stats)
stats->max_chunk_size = __UINT64_C(0);
stats->min_chunk_size = __UINT64_C(0xffffffffffffffff);
- for (i = 0; i < MEM_BUCKET_COUNT; i++)
+ for (i = 0; i < ZBX_SHMEM_BUCKET_COUNT; i++)
{
counter = 0;
chunk = info->buckets[i];
@@ -756,27 +756,27 @@ void zbx_mem_get_stats(const zbx_mem_info_t *info, zbx_mem_stats_t *stats)
}
stats->overhead = info->total_size - info->used_size - info->free_size;
- stats->used_chunks = stats->overhead / (2 * MEM_SIZE_FIELD) + 1 - stats->free_chunks;
+ stats->used_chunks = stats->overhead / (2 * SHMEM_SIZE_FIELD) + 1 - stats->free_chunks;
stats->free_size = info->free_size;
stats->used_size = info->used_size;
}
-void zbx_mem_dump_stats(int level, zbx_mem_info_t *info)
+void zbx_shmem_dump_stats(int level, zbx_shmem_info_t *info)
{
- zbx_mem_stats_t stats;
+ zbx_shmem_stats_t stats;
int i;
- zbx_mem_get_stats(info, &stats);
+ zbx_shmem_get_stats(info, &stats);
zabbix_log(level, "=== memory statistics for %s ===", info->mem_descr);
- for (i = 0; i < MEM_BUCKET_COUNT; i++)
+ for (i = 0; i < ZBX_SHMEM_BUCKET_COUNT; i++)
{
if (0 == stats.chunks_num[i])
continue;
- zabbix_log(level, "free chunks of size %2s %3d bytes: %8u", i == MEM_BUCKET_COUNT - 1 ? ">=" : "",
- MEM_MIN_BUCKET_SIZE + 8 * i, stats.chunks_num[i]);
+ zabbix_log(level, "free chunks of size %2s %3d bytes: %8u", i == ZBX_SHMEM_BUCKET_COUNT - 1 ? ">=" : "",
+ ZBX_SHMEM_MIN_BUCKET_SIZE + 8 * i, stats.chunks_num[i]);
}
zabbix_log(level, "min chunk size: %10llu bytes", (unsigned long long)stats.min_chunk_size);
@@ -795,7 +795,7 @@ void zbx_mem_dump_stats(int level, zbx_mem_info_t *info)
zabbix_log(level, "================================");
}
-size_t zbx_mem_required_size(int chunks_num, const char *descr, const char *param)
+size_t zbx_shmem_required_size(int chunks_num, const char *descr, const char *param)
{
size_t size = 0;
@@ -806,27 +806,27 @@ size_t zbx_mem_required_size(int chunks_num, const char *descr, const char *para
/* that we will be able to get ourselves 'chunks_num' pieces of memory with a */
/* total size of 'size', given that we also have to store 'descr' and 'param'? */
- size += 7; /* ensure we allocate enough to 8-align zbx_mem_info_t */
- size += sizeof(zbx_mem_info_t);
+ size += 7; /* ensure we allocate enough to 8-align zbx_shmem_info_t */
+ size += sizeof(zbx_shmem_info_t);
size += ZBX_PTR_SIZE - 1; /* ensure we allocate enough to align bucket pointers */
- size += ZBX_PTR_SIZE * MEM_BUCKET_COUNT;
+ size += ZBX_PTR_SIZE * ZBX_SHMEM_BUCKET_COUNT;
size += strlen(descr) + 1;
size += strlen(param) + 1;
- size += (MEM_SIZE_FIELD - 1) + 8; /* ensure we allocate enough to align the first chunk */
- size += (MEM_SIZE_FIELD - 1) + 8; /* ensure we allocate enough to align right size field */
+ size += (SHMEM_SIZE_FIELD - 1) + 8; /* ensure we allocate enough to align the first chunk */
+ size += (SHMEM_SIZE_FIELD - 1) + 8; /* ensure we allocate enough to align right size field */
- size += (chunks_num - 1) * MEM_SIZE_FIELD * 2; /* each additional chunk requires 16 bytes of overhead */
- size += chunks_num * (MEM_MIN_ALLOC - 1); /* each chunk has size of at least MEM_MIN_ALLOC bytes */
+ size += (chunks_num - 1) * SHMEM_SIZE_FIELD * 2;/* each additional chunk requires 16 bytes of overhead */
+ size += chunks_num * (SHMEM_MIN_ALLOC - 1); /* each chunk has size of at least SHMEM_MIN_ALLOC bytes */
zabbix_log(LOG_LEVEL_DEBUG, "End of %s() size:" ZBX_FS_SIZE_T, __func__, (zbx_fs_size_t)size);
return size;
}
-zbx_uint64_t zbx_mem_required_chunk_size(zbx_uint64_t size)
+zbx_uint64_t zbx_shmem_required_chunk_size(zbx_uint64_t size)
{
if (0 == size)
return 0;
- return mem_proper_alloc_size(size) + MEM_SIZE_FIELD * 2;
+ return mem_proper_alloc_size(size) + SHMEM_SIZE_FIELD * 2;
}
diff --git a/src/libs/zbxsysinfo/simple/simple.c b/src/libs/zbxsysinfo/simple/simple.c
index 469fbf7fbab..5ed55af6f2c 100644
--- a/src/libs/zbxsysinfo/simple/simple.c
+++ b/src/libs/zbxsysinfo/simple/simple.c
@@ -24,7 +24,6 @@
#include "zbxcomms.h"
#include "log.h"
#include "cfg.h"
-#include "telnet.h"
#include "../common/net.h"
#include "ntp.h"
@@ -238,7 +237,7 @@ static int check_telnet(const char *host, unsigned short port, int timeout, int
zbx_strerror(errno));
}
#endif
- if (SUCCEED == telnet_test_login(s.socket))
+ if (SUCCEED == zbx_telnet_test_login(s.socket))
*value_int = 1;
else
zabbix_log(LOG_LEVEL_DEBUG, "Telnet check error: no login prompt");
diff --git a/src/libs/zbxsysinfo/sysinfo.c b/src/libs/zbxsysinfo/sysinfo.c
index af3258266f1..e527d49f3b6 100644
--- a/src/libs/zbxsysinfo/sysinfo.c
+++ b/src/libs/zbxsysinfo/sysinfo.c
@@ -23,7 +23,7 @@
#include "alias.h"
#include "threads.h"
#if !defined(_WINDOWS) && !defined(__MINGW32__)
-#include "sighandler.h"
+#include "zbxnix.h"
#endif
#include "zbxalgo.h"
#include "zbxregexp.h"
diff --git a/src/libs/zbxsysinfo/win32/wmi.cpp b/src/libs/zbxsysinfo/win32/wmi.cpp
index ed3578bbea9..375446ad765 100644
--- a/src/libs/zbxsysinfo/win32/wmi.cpp
+++ b/src/libs/zbxsysinfo/win32/wmi.cpp
@@ -25,7 +25,6 @@ extern "C"
# include "sysinfo.h"
# include "log.h"
# include "zbxalgo.h"
-# include "../../zbxalgo/vectorimpl.h"
# include "zbxjson.h"
# include "cfg.h"
}
diff --git a/src/libs/zbxtrends/cache.c b/src/libs/zbxtrends/cache.c
index c8e8826622c..9041848d64e 100644
--- a/src/libs/zbxtrends/cache.c
+++ b/src/libs/zbxtrends/cache.c
@@ -22,7 +22,7 @@
#include "log.h"
#include "zbxtrends.h"
#include "mutexs.h"
-#include "memalloc.h"
+#include "zbxshmem.h"
#include "trends.h"
extern zbx_uint64_t CONFIG_TREND_FUNC_CACHE_SIZE;
@@ -73,11 +73,11 @@ static int alloc_num = 0;
* 2) indexing hashset slots pointer array, allocated during cache initialization
* 3) slots array, allocated during cache initialization and used for hashset entry allocations
*/
-static zbx_mem_info_t *tfc_mem = NULL;
+static zbx_shmem_info_t *tfc_mem = NULL;
static zbx_mutex_t tfc_lock = ZBX_MUTEX_NULL;
-ZBX_MEM_FUNC_IMPL(__tfc, tfc_mem)
+ZBX_SHMEM_FUNC_IMPL(__tfc, tfc_mem)
#define LOCK_CACHE zbx_mutex_lock(tfc_lock)
#define UNLOCK_CACHE zbx_mutex_unlock(tfc_lock)
@@ -157,7 +157,7 @@ static void *tfc_malloc_func(void *old, size_t size)
return tfc_alloc_slot();
if (0 == alloc_num++)
- return __tfc_mem_malloc_func(old, size);
+ return __tfc_shmem_malloc_func(old, size);
return NULL;
}
@@ -178,7 +178,7 @@ static void tfc_free_func(void *ptr)
return;
}
- __tfc_mem_free_func(ptr);
+ __tfc_shmem_free_func(ptr);
}
/******************************************************************************
@@ -388,15 +388,15 @@ int zbx_tfc_init(char **error)
if (SUCCEED != zbx_mutex_create(&tfc_lock, ZBX_MUTEX_TREND_FUNC, error))
goto out;
- size_reserved = zbx_mem_required_size(1, "trend function cache size", "TrendFunctionCacheSize");
+ size_reserved = zbx_shmem_required_size(1, "trend function cache size", "TrendFunctionCacheSize");
- if (SUCCEED != zbx_mem_create(&tfc_mem, CONFIG_TREND_FUNC_CACHE_SIZE, "trend function cache size",
+ if (SUCCEED != zbx_shmem_create(&tfc_mem, CONFIG_TREND_FUNC_CACHE_SIZE, "trend function cache size",
"TrendFunctionCacheSize", 1, error))
{
goto out;
}
- cache = (zbx_tfc_t *)__tfc_mem_realloc_func(NULL, sizeof(zbx_tfc_t));
+ cache = (zbx_tfc_t *)__tfc_shmem_realloc_func(NULL, sizeof(zbx_tfc_t));
size_actual = CONFIG_TREND_FUNC_CACHE_SIZE;
/* (8 + 8) * 3 - overhead for 3 allocations */
@@ -414,7 +414,7 @@ int zbx_tfc_init(char **error)
cache->lru_head = UINT32_MAX;
cache->lru_tail = UINT32_MAX;
- cache->slots = (zbx_tfc_slot_t *)__tfc_mem_malloc_func(NULL, sizeof(zbx_tfc_slot_t) * cache->slots_num);
+ cache->slots = (zbx_tfc_slot_t *)__tfc_shmem_malloc_func(NULL, sizeof(zbx_tfc_slot_t) * cache->slots_num);
cache->free_head = UINT32_MAX;
cache->free_slot = 0;
@@ -439,7 +439,7 @@ void zbx_tfc_destroy(void)
{
if (0 != CONFIG_TREND_FUNC_CACHE_SIZE)
{
- zbx_mem_destroy(tfc_mem);
+ zbx_shmem_destroy(tfc_mem);
tfc_mem = NULL;
zbx_mutex_destroy(&tfc_lock);
alloc_num = 0;
diff --git a/src/libs/zbxxml/xml.c b/src/libs/zbxxml/xml.c
index 98d05f17011..dd943cbf791 100644
--- a/src/libs/zbxxml/xml.c
+++ b/src/libs/zbxxml/xml.c
@@ -28,8 +28,6 @@
# include <libxml/xpath.h>
#endif
-#include "../zbxalgo/vectorimpl.h"
-
typedef struct _zbx_xml_node_t zbx_xml_node_t;
ZBX_PTR_VECTOR_DECL(xml_node_ptr, zbx_xml_node_t *)
diff --git a/src/zabbix_agent/active.c b/src/zabbix_agent/active.c
index a6b86de87ab..145cb5a672a 100644
--- a/src/zabbix_agent/active.c
+++ b/src/zabbix_agent/active.c
@@ -37,7 +37,7 @@ extern ZBX_THREAD_LOCAL char *CONFIG_HOSTNAME;
#if defined(ZABBIX_SERVICE)
# include "service.h"
#elif defined(ZABBIX_DAEMON)
-# include "daemon.h"
+# include "zbxnix.h"
#endif
#include "zbxcrypto.h"
diff --git a/src/zabbix_agent/listener.c b/src/zabbix_agent/listener.c
index 6e67a3f373e..ea6ae1d1750 100644
--- a/src/zabbix_agent/listener.c
+++ b/src/zabbix_agent/listener.c
@@ -31,7 +31,7 @@ extern ZBX_THREAD_LOCAL int server_num, process_num;
#if defined(ZABBIX_SERVICE)
# include "service.h"
#elif defined(ZABBIX_DAEMON)
-# include "daemon.h"
+# include "zbxnix.h"
#endif
#include "zbxcrypto.h"
diff --git a/src/zabbix_agent/logfiles/persistent_state.c b/src/zabbix_agent/logfiles/persistent_state.c
index a59e651e67b..4622c76b893 100644
--- a/src/zabbix_agent/logfiles/persistent_state.c
+++ b/src/zabbix_agent/logfiles/persistent_state.c
@@ -23,7 +23,6 @@
#include "logfiles.h"
#include "zbxjson.h"
#include "zbxcrypto.h"
-#include "../../libs/zbxalgo/vectorimpl.h"
/* tags for agent persistent storage files */
#define ZBX_PERSIST_TAG_FILENAME "filename"
diff --git a/src/zabbix_agent/procstat.c b/src/zabbix_agent/procstat.c
index e7b8613df34..40383921df7 100644
--- a/src/zabbix_agent/procstat.c
+++ b/src/zabbix_agent/procstat.c
@@ -21,7 +21,7 @@
#include "log.h"
#include "stats.h"
-#include "ipc.h"
+#include "zbxnix.h"
#ifdef ZBX_PROCSTAT_COLLECTOR
diff --git a/src/zabbix_agent/stats.c b/src/zabbix_agent/stats.c
index 22187800a13..dcb40af24d9 100644
--- a/src/zabbix_agent/stats.c
+++ b/src/zabbix_agent/stats.c
@@ -29,7 +29,7 @@
/* defined in sysinfo lib */
extern int get_cpu_num_win32(void);
#else
-# include "daemon.h"
+# include "zbxnix.h"
#endif
ZBX_COLLECTOR_DATA *collector = NULL;
diff --git a/src/zabbix_agent/stats.h b/src/zabbix_agent/stats.h
index a858cd8b9b5..9020fc23660 100644
--- a/src/zabbix_agent/stats.h
+++ b/src/zabbix_agent/stats.h
@@ -24,7 +24,7 @@
#ifndef _WINDOWS
# include "diskdevices.h"
-# include "ipc.h"
+# include "zbxnix.h"
#endif
#include "cpustat.h"
diff --git a/src/zabbix_agent/zabbix_agentd.c b/src/zabbix_agent/zabbix_agentd.c
index 454d1c404f5..e66fea0b8d4 100644
--- a/src/zabbix_agent/zabbix_agentd.c
+++ b/src/zabbix_agent/zabbix_agentd.c
@@ -103,8 +103,6 @@ int CONFIG_TCP_MAX_BACKLOG_SIZE = SOMAXCONN;
# include "perfstat.h"
#else
# include "zbxnix.h"
-# include "sighandler.h"
-# include "daemon.h"
#endif
#include "active.h"
#include "listener.h"
@@ -114,7 +112,7 @@ int CONFIG_TCP_MAX_BACKLOG_SIZE = SOMAXCONN;
#if defined(ZABBIX_SERVICE)
# include "service.h"
#elif defined(ZABBIX_DAEMON)
-# include "daemon.h"
+# include "zbxnix.h"
#endif
#include "setproctitle.h"
@@ -360,7 +358,7 @@ static int parse_commandline(int argc, char **argv, ZBX_TASK_EX *t)
break;
#ifndef _WINDOWS
case 'R':
- if (SUCCEED != parse_rtc_options(zbx_optarg, &t->data))
+ if (SUCCEED != zbx_parse_rtc_options(zbx_optarg, &t->data))
exit(EXIT_FAILURE);
t->task = ZBX_TASK_RUNTIME_CONTROL;
@@ -1464,7 +1462,7 @@ int main(int argc, char **argv)
break;
}
- START_MAIN_ZABBIX_ENTRY(CONFIG_ALLOW_ROOT, CONFIG_USER, t.flags);
+ ZBX_START_MAIN_ZABBIX_ENTRY(CONFIG_ALLOW_ROOT, CONFIG_USER, t.flags);
exit(EXIT_SUCCESS);
}
diff --git a/src/zabbix_proxy/Makefile.am b/src/zabbix_proxy/Makefile.am
index e427a042ccf..4c13c203bbf 100644
--- a/src/zabbix_proxy/Makefile.am
+++ b/src/zabbix_proxy/Makefile.am
@@ -55,7 +55,7 @@ zabbix_proxy_LDADD = \
$(top_builddir)/src/libs/zbxserver/libzbxserver_proxy.a \
$(top_builddir)/src/libs/zbxeval/libzbxeval.a \
$(top_builddir)/src/libs/zbxhistory/libzbxhistory.a \
- $(top_builddir)/src/libs/zbxmemory/libzbxmemory.a \
+ $(top_builddir)/src/libs/zbxshmem/libzbxshmem.a \
$(top_builddir)/src/libs/zbxregexp/libzbxregexp.a \
$(top_builddir)/src/libs/zbxself/libzbxself.a \
$(top_builddir)/src/libs/zbxself/libzbxself_proxy.a \
diff --git a/src/zabbix_proxy/datasender/datasender.c b/src/zabbix_proxy/datasender/datasender.c
index 63516c2da11..16f7278c363 100644
--- a/src/zabbix_proxy/datasender/datasender.c
+++ b/src/zabbix_proxy/datasender/datasender.c
@@ -22,7 +22,7 @@
#include "zbxcommshigh.h"
#include "db.h"
#include "log.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "proxy.h"
#include "zbxself.h"
#include "zbxtasks.h"
diff --git a/src/zabbix_proxy/heart/heart.c b/src/zabbix_proxy/heart/heart.c
index 9e8344f0e7a..179a0218c68 100644
--- a/src/zabbix_proxy/heart/heart.c
+++ b/src/zabbix_proxy/heart/heart.c
@@ -19,7 +19,7 @@
#include "heart.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "log.h"
#include "zbxjson.h"
#include "zbxself.h"
diff --git a/src/zabbix_proxy/housekeeper/housekeeper.c b/src/zabbix_proxy/housekeeper/housekeeper.c
index a52f3649e0a..fcdce043a82 100644
--- a/src/zabbix_proxy/housekeeper/housekeeper.c
+++ b/src/zabbix_proxy/housekeeper/housekeeper.c
@@ -20,7 +20,7 @@
#include "housekeeper.h"
#include "log.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxself.h"
#include "dbcache.h"
#include "zbxrtc.h"
diff --git a/src/zabbix_proxy/proxy.c b/src/zabbix_proxy/proxy.c
index 5291d45a76d..dd057b1b673 100644
--- a/src/zabbix_proxy/proxy.c
+++ b/src/zabbix_proxy/proxy.c
@@ -30,7 +30,6 @@
#include "zbxmodules.h"
#include "zbxnix.h"
-#include "daemon.h"
#include "zbxself.h"
#include "../zabbix_server/dbsyncer/dbsyncer.h"
@@ -55,7 +54,6 @@
#include "../zabbix_server/availability/avail_manager.h"
#include "../libs/zbxvault/vault.h"
#include "zbxdiag.h"
-#include "sighandler.h"
#include "zbxrtc.h"
#ifdef HAVE_OPENIPMI
@@ -1037,7 +1035,7 @@ int main(int argc, char **argv)
exit(SUCCEED == ret ? EXIT_SUCCESS : EXIT_FAILURE);
}
- return daemon_start(CONFIG_ALLOW_ROOT, CONFIG_USER, t.flags);
+ return zbx_daemon_start(CONFIG_ALLOW_ROOT, CONFIG_USER, t.flags);
}
static void zbx_check_db(void)
diff --git a/src/zabbix_proxy/proxyconfig/proxyconfig.c b/src/zabbix_proxy/proxyconfig/proxyconfig.c
index f35efc61b4d..9bd68553b83 100644
--- a/src/zabbix_proxy/proxyconfig/proxyconfig.c
+++ b/src/zabbix_proxy/proxyconfig/proxyconfig.c
@@ -20,7 +20,7 @@
#include "proxyconfig.h"
#include "log.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "proxy.h"
#include "zbxself.h"
diff --git a/src/zabbix_proxy/taskmanager/taskmanager.c b/src/zabbix_proxy/taskmanager/taskmanager.c
index 8e38c63880a..2057925e6ae 100644
--- a/src/zabbix_proxy/taskmanager/taskmanager.c
+++ b/src/zabbix_proxy/taskmanager/taskmanager.c
@@ -19,7 +19,7 @@
#include "taskmanager.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxself.h"
#include "zbxtasks.h"
#include "log.h"
diff --git a/src/zabbix_server/Makefile.am b/src/zabbix_server/Makefile.am
index ae986fbc970..a056b208c92 100644
--- a/src/zabbix_server/Makefile.am
+++ b/src/zabbix_server/Makefile.am
@@ -88,7 +88,7 @@ zabbix_server_LDADD = \
$(top_builddir)/src/libs/zbxserver/libzbxserver.a \
$(top_builddir)/src/libs/zbxeval/libzbxeval.a \
$(top_builddir)/src/libs/zbxhistory/libzbxhistory.a \
- $(top_builddir)/src/libs/zbxmemory/libzbxmemory.a \
+ $(top_builddir)/src/libs/zbxshmem/libzbxshmem.a \
$(top_builddir)/src/libs/zbxregexp/libzbxregexp.a \
$(top_builddir)/src/libs/zbxself/libzbxself.a \
$(top_builddir)/src/libs/zbxself/libzbxself_server.a \
diff --git a/src/zabbix_server/actions.c b/src/zabbix_server/actions.c
index a17b57e55d9..2309db15d44 100644
--- a/src/zabbix_server/actions.c
+++ b/src/zabbix_server/actions.c
@@ -2647,7 +2647,7 @@ static int check_action_conditions(zbx_uint64_t eventid, const zbx_action_eval_t
if (CONDITION_EVAL_TYPE_EXPRESSION == action->evaltype)
{
- if (SUCCEED == evaluate(&eval_result, expression, error, sizeof(error), NULL))
+ if (SUCCEED == zbx_evaluate(&eval_result, expression, error, sizeof(error), NULL))
ret = (SUCCEED != zbx_double_compare(eval_result, 0) ? SUCCEED : FAIL);
zbx_free(expression);
diff --git a/src/zabbix_server/alerter/alert_manager.c b/src/zabbix_server/alerter/alert_manager.c
index 3c34f8255b7..30543c50222 100644
--- a/src/zabbix_server/alerter/alert_manager.c
+++ b/src/zabbix_server/alerter/alert_manager.c
@@ -19,7 +19,7 @@
#include "alert_manager.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxself.h"
#include "log.h"
#include "zbxserver.h"
@@ -34,8 +34,8 @@
#define ZBX_UPDATE_STR(dst, src) \
if (NULL == src) \
- zbx_free(dst); \
- else if (NULL == dst || 0 != strcmp(dst, src)) \
+ zbx_free(dst); \
+ else if (NULL == dst || 0 != strcmp(dst, src)) \
dst = zbx_strdup(dst, src);
#define ZBX_AM_DB_POLL_DELAY 1
@@ -2199,8 +2199,8 @@ static void am_process_diag_top_sources(zbx_am_t *manager, zbx_ipc_client_t *cli
if (NULL == (source = zbx_hashset_search(&sources, &source_local)))
{
+ source_local.alerts_num = 0;
source = zbx_hashset_insert(&sources, &source_local, sizeof(source_local));
- source->alerts_num = 0;
zbx_vector_ptr_append(&view, source);
}
source->alerts_num++;
diff --git a/src/zabbix_server/alerter/alert_syncer.c b/src/zabbix_server/alerter/alert_syncer.c
index 6dac2822384..14793e9feff 100644
--- a/src/zabbix_server/alerter/alert_syncer.c
+++ b/src/zabbix_server/alerter/alert_syncer.c
@@ -19,12 +19,11 @@
#include "alert_syncer.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxself.h"
#include "log.h"
#include "alerter_protocol.h"
#include "service_protocol.h"
-#include "../../libs/zbxalgo/vectorimpl.h"
#include "dbcache.h"
#define ZBX_POLL_INTERVAL 1
diff --git a/src/zabbix_server/alerter/alerter.c b/src/zabbix_server/alerter/alerter.c
index 0439b0acff4..41594e855db 100644
--- a/src/zabbix_server/alerter/alerter.c
+++ b/src/zabbix_server/alerter/alerter.c
@@ -20,7 +20,7 @@
#include "alerter.h"
#include "log.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxmedia.h"
#include "zbxself.h"
#include "zbxexec.h"
diff --git a/src/zabbix_server/availability/avail_manager.c b/src/zabbix_server/availability/avail_manager.c
index 091b78f7a2b..641df3998bf 100644
--- a/src/zabbix_server/availability/avail_manager.c
+++ b/src/zabbix_server/availability/avail_manager.c
@@ -23,12 +23,10 @@
#include "zbxself.h"
#include "zbxavailability.h"
#include "zbxipcservice.h"
-#include "daemon.h"
-#include "sighandler.h"
+#include "zbxnix.h"
#include "dbcache.h"
#include "avail_protocol.h"
-
extern ZBX_THREAD_LOCAL unsigned char process_type;
extern unsigned char program_type;
extern ZBX_THREAD_LOCAL int server_num, process_num;
diff --git a/src/zabbix_server/dbconfig/dbconfig.c b/src/zabbix_server/dbconfig/dbconfig.c
index 50969165ba0..afb4f193fca 100644
--- a/src/zabbix_server/dbconfig/dbconfig.c
+++ b/src/zabbix_server/dbconfig/dbconfig.c
@@ -19,7 +19,7 @@
#include "dbconfig.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxself.h"
#include "log.h"
#include "dbcache.h"
diff --git a/src/zabbix_server/dbsyncer/dbsyncer.c b/src/zabbix_server/dbsyncer/dbsyncer.c
index b7f0b62a7a9..f58606c7c16 100644
--- a/src/zabbix_server/dbsyncer/dbsyncer.c
+++ b/src/zabbix_server/dbsyncer/dbsyncer.c
@@ -20,9 +20,8 @@
#include "dbsyncer.h"
#include "log.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxself.h"
-#include "sighandler.h"
#include "dbcache.h"
#include "export.h"
diff --git a/src/zabbix_server/discoverer/discoverer.c b/src/zabbix_server/discoverer/discoverer.c
index 0217be641a2..5bd542b119c 100644
--- a/src/zabbix_server/discoverer/discoverer.c
+++ b/src/zabbix_server/discoverer/discoverer.c
@@ -26,7 +26,7 @@
#include "zbxself.h"
#include "zbxrtc.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "../poller/checks_agent.h"
#include "../poller/checks_snmp.h"
#include "zbxcrypto.h"
diff --git a/src/zabbix_server/escalator/escalator.c b/src/zabbix_server/escalator/escalator.c
index 488d5ed91eb..36b686ca10c 100644
--- a/src/zabbix_server/escalator/escalator.c
+++ b/src/zabbix_server/escalator/escalator.c
@@ -19,10 +19,9 @@
#include "escalator.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxserver.h"
#include "zbxself.h"
-#include "../../libs/zbxalgo/vectorimpl.h"
#include "../actions.h"
#include "../scripts/scripts.h"
#include "zbxcrypto.h"
diff --git a/src/zabbix_server/events.c b/src/zabbix_server/events.c
index 5fa9b5b4842..935e7a0a022 100644
--- a/src/zabbix_server/events.c
+++ b/src/zabbix_server/events.c
@@ -809,7 +809,7 @@ static zbx_correlation_match_result_t correlation_match_new_event(zbx_correlatio
pos = token.loc.r;
}
- if (SUCCEED == evaluate_unknown(expression, &result, error, sizeof(error)))
+ if (SUCCEED == zbx_evaluate_unknown(expression, &result, error, sizeof(error)))
{
if (result == ZBX_UNKNOWN)
ret = CORRELATION_MAY_MATCH;
diff --git a/src/zabbix_server/ha/ha_manager.c b/src/zabbix_server/ha/ha_manager.c
index 7ab6cedfe66..bc4c64cc628 100644
--- a/src/zabbix_server/ha/ha_manager.c
+++ b/src/zabbix_server/ha/ha_manager.c
@@ -25,7 +25,6 @@
#include "zbxserialize.h"
#include "threads.h"
#include "mutexs.h"
-#include "../../libs/zbxalgo/vectorimpl.h"
#include "../../libs/zbxaudit/audit.h"
#include "../../libs/zbxaudit/audit_ha.h"
#include "../../libs/zbxaudit/audit_settings.h"
diff --git a/src/zabbix_server/housekeeper/housekeeper.c b/src/zabbix_server/housekeeper/housekeeper.c
index cb99393cbc0..a8ac984be6e 100644
--- a/src/zabbix_server/housekeeper/housekeeper.c
+++ b/src/zabbix_server/housekeeper/housekeeper.c
@@ -19,7 +19,7 @@
#include "housekeeper.h"
#include "log.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxself.h"
#include "zbxserver.h"
#include "zbxrtc.h"
diff --git a/src/zabbix_server/housekeeper/trigger_housekeeper.c b/src/zabbix_server/housekeeper/trigger_housekeeper.c
index 68596044815..e49049da751 100644
--- a/src/zabbix_server/housekeeper/trigger_housekeeper.c
+++ b/src/zabbix_server/housekeeper/trigger_housekeeper.c
@@ -21,7 +21,7 @@
#include "log.h"
#include "zbxself.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "service_protocol.h"
#include "zbxrtc.h"
diff --git a/src/zabbix_server/httppoller/httppoller.c b/src/zabbix_server/httppoller/httppoller.c
index 8004df11c45..e80d6a9d5d4 100644
--- a/src/zabbix_server/httppoller/httppoller.c
+++ b/src/zabbix_server/httppoller/httppoller.c
@@ -22,7 +22,7 @@
#include "common.h"
#include "db.h"
#include "log.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxself.h"
#include "httptest.h"
diff --git a/src/zabbix_server/httppoller/httptest.c b/src/zabbix_server/httppoller/httptest.c
index b7006a736d0..bd73a78c75c 100644
--- a/src/zabbix_server/httppoller/httptest.c
+++ b/src/zabbix_server/httppoller/httptest.c
@@ -21,7 +21,7 @@
#include "log.h"
#include "preproc.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxserver.h"
#include "zbxregexp.h"
#include "zbxhttp.h"
diff --git a/src/zabbix_server/ipmi/ipmi_manager.c b/src/zabbix_server/ipmi/ipmi_manager.c
index 1f8cf3ab1a4..558b1ccd2b1 100644
--- a/src/zabbix_server/ipmi/ipmi_manager.c
+++ b/src/zabbix_server/ipmi/ipmi_manager.c
@@ -23,7 +23,7 @@
#include "ipmi_manager.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxself.h"
#include "log.h"
#include "zbxipcservice.h"
@@ -588,13 +588,14 @@ static zbx_ipmi_manager_host_t *ipmi_manager_cache_host(zbx_ipmi_manager_t *mana
zbx_ipmi_manager_host_t host_local;
host_local.hostid = hostid;
- host = (zbx_ipmi_manager_host_t *)zbx_hashset_insert(&manager->hosts, &host_local, sizeof(host_local));
+ host_local.disable_until = 0;
+ host_local.poller = ipmi_manager_get_host_poller(manager);
+ host_local.lastcheck = now;
- host->disable_until = 0;
- host->poller = ipmi_manager_get_host_poller(manager);
+ host = (zbx_ipmi_manager_host_t *)zbx_hashset_insert(&manager->hosts, &host_local, sizeof(host_local));
}
-
- host->lastcheck = now;
+ else
+ host->lastcheck = now;
return host;
}
diff --git a/src/zabbix_server/ipmi/ipmi_poller.c b/src/zabbix_server/ipmi/ipmi_poller.c
index 36eec2c71b5..eae6d00cec0 100644
--- a/src/zabbix_server/ipmi/ipmi_poller.c
+++ b/src/zabbix_server/ipmi/ipmi_poller.c
@@ -23,7 +23,7 @@
#include "ipmi_poller.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxself.h"
#include "log.h"
#include "zbxipcservice.h"
diff --git a/src/zabbix_server/lld/lld.c b/src/zabbix_server/lld/lld.c
index 6bf5120538e..1ac6fe02e39 100644
--- a/src/zabbix_server/lld/lld.c
+++ b/src/zabbix_server/lld/lld.c
@@ -394,7 +394,7 @@ static int filter_evaluate_or(const lld_filter_t *filter, const struct zbx_json_
* *
* Comments: 1) replace {item_condition} references with action condition *
* evaluation results (1 or 0) *
- * 2) call evaluate() to calculate the final result *
+ * 2) call zbx_evaluate() to calculate the final result *
* *
******************************************************************************/
static int filter_evaluate_expression(const lld_filter_t *filter, const struct zbx_json_parse *jp_row,
@@ -427,7 +427,7 @@ static int filter_evaluate_expression(const lld_filter_t *filter, const struct z
}
}
- if (SUCCEED == evaluate(&result, expression, error, sizeof(error), NULL))
+ if (SUCCEED == zbx_evaluate(&result, expression, error, sizeof(error), NULL))
ret = (SUCCEED != zbx_double_compare(result, 0) ? SUCCEED : FAIL);
zbx_free(expression);
diff --git a/src/zabbix_server/lld/lld_manager.c b/src/zabbix_server/lld/lld_manager.c
index 774c9f7ffac..9ef208f22cb 100644
--- a/src/zabbix_server/lld/lld_manager.c
+++ b/src/zabbix_server/lld/lld_manager.c
@@ -19,7 +19,7 @@
#include "lld_manager.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxself.h"
#include "log.h"
#include "zbxipcservice.h"
diff --git a/src/zabbix_server/lld/lld_worker.c b/src/zabbix_server/lld/lld_worker.c
index 55740eae00b..b8fff40da77 100644
--- a/src/zabbix_server/lld/lld_worker.c
+++ b/src/zabbix_server/lld/lld_worker.c
@@ -19,7 +19,7 @@
#include "lld_worker.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "log.h"
#include "zbxipcservice.h"
#include "zbxself.h"
diff --git a/src/zabbix_server/pinger/pinger.c b/src/zabbix_server/pinger/pinger.c
index 500d1929a79..64629dc3eae 100644
--- a/src/zabbix_server/pinger/pinger.c
+++ b/src/zabbix_server/pinger/pinger.c
@@ -22,7 +22,7 @@
#include "log.h"
#include "zbxserver.h"
#include "zbxicmpping.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxself.h"
#include "preproc.h"
diff --git a/src/zabbix_server/poller/checks_snmp.c b/src/zabbix_server/poller/checks_snmp.c
index c92ae465afd..9def7bd59bc 100644
--- a/src/zabbix_server/poller/checks_snmp.c
+++ b/src/zabbix_server/poller/checks_snmp.c
@@ -294,7 +294,8 @@ static void cache_put_snmp_index(const DC_ITEM *item, const char *snmp_oid, cons
__snmpidx_mapping_hash, __snmpidx_mapping_compare, __snmpidx_mapping_clean,
ZBX_DEFAULT_MEM_MALLOC_FUNC, ZBX_DEFAULT_MEM_REALLOC_FUNC, ZBX_DEFAULT_MEM_FREE_FUNC);
- main_key = (zbx_snmpidx_main_key_t *)zbx_hashset_insert(&snmpidx, &main_key_local, sizeof(main_key_local));
+ main_key = (zbx_snmpidx_main_key_t *)zbx_hashset_insert(&snmpidx, &main_key_local,
+ sizeof(main_key_local));
}
if (NULL == (mapping = (zbx_snmpidx_mapping_t *)zbx_hashset_search(main_key->mappings, &value)))
diff --git a/src/zabbix_server/poller/checks_telnet.c b/src/zabbix_server/poller/checks_telnet.c
index e736c0d33a4..e0c011de7d9 100644
--- a/src/zabbix_server/poller/checks_telnet.c
+++ b/src/zabbix_server/poller/checks_telnet.c
@@ -19,7 +19,6 @@
#include "checks_telnet.h"
-#include "telnet.h"
#include "zbxcomms.h"
#include "log.h"
@@ -57,10 +56,10 @@ static int telnet_run(DC_ITEM *item, AGENT_RESULT *result, const char *encoding)
zbx_strerror(errno)));
}
- if (FAIL == telnet_login(s.socket, item->username, item->password, result))
+ if (FAIL == zbx_telnet_login(s.socket, item->username, item->password, result))
goto tcp_close;
- if (FAIL == telnet_execute(s.socket, item->params, result, encoding))
+ if (FAIL == zbx_telnet_execute(s.socket, item->params, result, encoding))
goto tcp_close;
ret = SUCCEED;
@@ -123,3 +122,5 @@ out:
return ret;
}
+
+#undef TELNET_RUN_KEY
diff --git a/src/zabbix_server/poller/poller.c b/src/zabbix_server/poller/poller.c
index ee9048b22e5..7a172072e22 100644
--- a/src/zabbix_server/poller/poller.c
+++ b/src/zabbix_server/poller/poller.c
@@ -19,7 +19,7 @@
#include "poller.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxserver.h"
#include "zbxself.h"
#include "preproc.h"
diff --git a/src/zabbix_server/preprocessor/preproc_cache.c b/src/zabbix_server/preprocessor/preproc_cache.c
index 1ea66e5267a..9b7cff0731e 100644
--- a/src/zabbix_server/preprocessor/preproc_cache.c
+++ b/src/zabbix_server/preprocessor/preproc_cache.c
@@ -17,7 +17,6 @@
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
-#include "../../libs/zbxalgo/vectorimpl.h"
#include "zbxprometheus.h"
#include "item_preproc.h"
diff --git a/src/zabbix_server/preprocessor/preproc_manager.c b/src/zabbix_server/preprocessor/preproc_manager.c
index 19f21b5c3f5..99d59c9ca72 100644
--- a/src/zabbix_server/preprocessor/preproc_manager.c
+++ b/src/zabbix_server/preprocessor/preproc_manager.c
@@ -19,7 +19,7 @@
#include "preproc_manager.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxself.h"
#include "log.h"
#include "zbxlld.h"
@@ -1300,9 +1300,10 @@ static void preprocessor_update_history(zbx_preprocessing_manager_t *manager, zb
zbx_preproc_history_t history_local;
history_local.itemid = itemid;
+ zbx_vector_ptr_create(&history_local.history);
+
vault = (zbx_preproc_history_t *)zbx_hashset_insert(&manager->history_cache, &history_local,
sizeof(history_local));
- zbx_vector_ptr_create(&vault->history);
}
zbx_vector_ptr_append_array(&vault->history, history->values, history->values_num);
diff --git a/src/zabbix_server/preprocessor/preproc_worker.c b/src/zabbix_server/preprocessor/preproc_worker.c
index 96edee89e0a..7b8c3739bd6 100644
--- a/src/zabbix_server/preprocessor/preproc_worker.c
+++ b/src/zabbix_server/preprocessor/preproc_worker.c
@@ -20,7 +20,7 @@
#include "preproc_worker.h"
#include "common.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxself.h"
#include "log.h"
#include "zbxipcservice.h"
diff --git a/src/zabbix_server/preprocessor/preprocessing.c b/src/zabbix_server/preprocessor/preprocessing.c
index c7a0a841b46..729ed3e8fdf 100644
--- a/src/zabbix_server/preprocessor/preprocessing.c
+++ b/src/zabbix_server/preprocessor/preprocessing.c
@@ -24,7 +24,6 @@
#include "zbxserialize.h"
#include "preproc_history.h"
#include "item_preproc.h"
-#include "../../libs/zbxalgo/vectorimpl.h"
#define PACKED_FIELD_RAW 0
#define PACKED_FIELD_STRING 1
diff --git a/src/zabbix_server/proxypoller/proxypoller.c b/src/zabbix_server/proxypoller/proxypoller.c
index 28661633cc2..041ca3fdcc7 100644
--- a/src/zabbix_server/proxypoller/proxypoller.c
+++ b/src/zabbix_server/proxypoller/proxypoller.c
@@ -20,7 +20,7 @@
#include "proxypoller.h"
#include "common.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxself.h"
#include "zbxserver.h"
#include "db.h"
diff --git a/src/zabbix_server/reporter/report_manager.c b/src/zabbix_server/reporter/report_manager.c
index d1485f0859f..9115d92286e 100644
--- a/src/zabbix_server/reporter/report_manager.c
+++ b/src/zabbix_server/reporter/report_manager.c
@@ -20,13 +20,12 @@
#include "report_manager.h"
#include "zbxself.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "base64.h"
#include "zbxreport.h"
#include "zbxhash.h"
#include "../../libs/zbxcrypto/hmac_sha256.h"
#include "sha256crypt.h"
-#include "../../libs/zbxalgo/vectorimpl.h"
#include "zbxalert.h"
#include "zbxserver.h"
#include "report_protocol.h"
@@ -1056,21 +1055,30 @@ static void rm_update_cache_reports(zbx_rm_t *manager, int now)
if (NULL == (report = (zbx_rm_report_t *)zbx_hashset_search(&manager->reports, &reportid)))
{
report_local.reportid = reportid;
+ ZBX_STR2UINT64(report_local.userid, row[1]);
+ ZBX_STR2UINT64(report_local.dashboardid, row[3]);
+ report_local.name = zbx_strdup(NULL, row[2]);
+ report_local.timezone = zbx_strdup(NULL, tz);
+ report_local.error = zbx_strdup(NULL, row[12]);
+ ZBX_STR2UCHAR(report_local.period, row[4]);
+ ZBX_STR2UCHAR(report_local.cycle, row[5]);
+ ZBX_STR2UCHAR(report_local.weekdays, row[6]);
+ ZBX_STR2UCHAR(report_local.status, row[14]);
+ report_local.start_time = atoi(row[7]);
+ ZBX_STR2UCHAR(report_local.state, row[11]);
+ report_local.flags = 0;
+ report_local.nextcheck = 0;
+ report_local.active_since = atoi(row[8]);
+ report_local.active_till = atoi(row[9]);
+ report_local.lastsent = atoi(row[13]);
+ zbx_vector_ptr_pair_create(&report_local.params);
+ zbx_vector_recipient_create(&report_local.usergroups);
+ zbx_vector_recipient_create(&report_local.users);
+ zbx_vector_uint64_create(&report_local.users_excl);
+
report = (zbx_rm_report_t *)zbx_hashset_insert(&manager->reports, &report_local,
sizeof(report_local));
- zbx_vector_ptr_pair_create(&report->params);
- zbx_vector_recipient_create(&report->usergroups);
- zbx_vector_recipient_create(&report->users);
- zbx_vector_uint64_create(&report->users_excl);
- report->name = zbx_strdup(NULL, row[2]);
- report->timezone = zbx_strdup(NULL, tz);
- report->nextcheck = 0;
- ZBX_STR2UCHAR(report->state, row[11]);
- report->error = zbx_strdup(NULL, row[12]);
- report->lastsent = atoi(row[13]);
- report->flags = 0;
-
reschedule = 1;
}
else
@@ -1090,17 +1098,17 @@ static void rm_update_cache_reports(zbx_rm_t *manager, int now)
report->timezone = zbx_strdup(report->timezone, tz);
reschedule = 1;
}
- }
- ZBX_STR2UINT64(report->userid, row[1]);
- ZBX_STR2UINT64(report->dashboardid, row[3]);
- ZBX_STR2UCHAR(report->period, row[4]);
- ZBX_STR2UCHAR(report->cycle, row[5]);
- ZBX_STR2UCHAR(report->weekdays, row[6]);
- report->start_time = atoi(row[7]);
- report->active_since = atoi(row[8]);
- report->active_till = atoi(row[9]);
- ZBX_STR2UCHAR(report->status, row[14]);
+ ZBX_STR2UINT64(report->userid, row[1]);
+ ZBX_STR2UINT64(report->dashboardid, row[3]);
+ ZBX_STR2UCHAR(report->period, row[4]);
+ ZBX_STR2UCHAR(report->cycle, row[5]);
+ ZBX_STR2UCHAR(report->weekdays, row[6]);
+ report->start_time = atoi(row[7]);
+ report->active_since = atoi(row[8]);
+ report->active_till = atoi(row[9]);
+ ZBX_STR2UCHAR(report->status, row[14]);
+ }
if (ZBX_REPORT_STATUS_DISABLED == report->status)
{
diff --git a/src/zabbix_server/reporter/report_writer.c b/src/zabbix_server/reporter/report_writer.c
index 1de9efdc81d..196a4cc87b7 100644
--- a/src/zabbix_server/reporter/report_writer.c
+++ b/src/zabbix_server/reporter/report_writer.c
@@ -19,7 +19,7 @@
#include "report_writer.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxself.h"
#include "log.h"
#include "zbxjson.h"
diff --git a/src/zabbix_server/selfmon/selfmon.c b/src/zabbix_server/selfmon/selfmon.c
index bc38d6d32db..dafdc639a47 100644
--- a/src/zabbix_server/selfmon/selfmon.c
+++ b/src/zabbix_server/selfmon/selfmon.c
@@ -19,7 +19,7 @@
#include "selfmon.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxself.h"
#include "log.h"
diff --git a/src/zabbix_server/server.c b/src/zabbix_server/server.c
index 48b36fe1995..fa535c53775 100644
--- a/src/zabbix_server/server.c
+++ b/src/zabbix_server/server.c
@@ -25,7 +25,6 @@
#include "export.h"
#include "zbxself.h"
-#include "sighandler.h"
#include "cfg.h"
#include "zbxdbupgrade.h"
@@ -34,7 +33,6 @@
#include "mutexs.h"
#include "zbxmodules.h"
#include "zbxnix.h"
-#include "daemon.h"
#include "alerter/alerter.h"
#include "alerter/alert_manager.h"
@@ -1096,7 +1094,7 @@ int main(int argc, char **argv)
exit(SUCCEED == ret ? EXIT_SUCCESS : EXIT_FAILURE);
}
- return daemon_start(CONFIG_ALLOW_ROOT, CONFIG_USER, t.flags);
+ return zbx_daemon_start(CONFIG_ALLOW_ROOT, CONFIG_USER, t.flags);
}
static void zbx_check_db(void)
diff --git a/src/zabbix_server/service/service_actions.c b/src/zabbix_server/service/service_actions.c
index e035edcc4ad..61dd72651ba 100644
--- a/src/zabbix_server/service/service_actions.c
+++ b/src/zabbix_server/service/service_actions.c
@@ -209,7 +209,7 @@ static int service_update_match_action(const zbx_service_update_t *update, const
zbx_strcpy_alloc(&expr, &expr_alloc, &expr_offset, action->formula + last_pos);
- if (FAIL == evaluate(&res, expr, error, sizeof(error), NULL))
+ if (FAIL == zbx_evaluate(&res, expr, error, sizeof(error), NULL))
{
zabbix_log(LOG_LEVEL_DEBUG, "cannot evaluate action \"" ZBX_FS_UI64 "\" formula \"%s\": %s",
action->actionid, action->formula, error);
diff --git a/src/zabbix_server/service/service_manager.c b/src/zabbix_server/service/service_manager.c
index 2398f82f0e4..f64364f581b 100644
--- a/src/zabbix_server/service/service_manager.c
+++ b/src/zabbix_server/service/service_manager.c
@@ -21,7 +21,7 @@
#include "log.h"
#include "zbxself.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "service_protocol.h"
#include "service_actions.h"
#include "zbxserialize.h"
diff --git a/src/zabbix_server/snmptrapper/snmptrapper.c b/src/zabbix_server/snmptrapper/snmptrapper.c
index d5d3aebbc89..66ff3e43351 100644
--- a/src/zabbix_server/snmptrapper/snmptrapper.c
+++ b/src/zabbix_server/snmptrapper/snmptrapper.c
@@ -20,7 +20,7 @@
#include "snmptrapper.h"
#include "zbxself.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "log.h"
#include "proxy.h"
#include "zbxserver.h"
diff --git a/src/zabbix_server/taskmanager/taskmanager.c b/src/zabbix_server/taskmanager/taskmanager.c
index 5d6a97c8fbb..e0788e9da0e 100644
--- a/src/zabbix_server/taskmanager/taskmanager.c
+++ b/src/zabbix_server/taskmanager/taskmanager.c
@@ -19,7 +19,7 @@
#include "taskmanager.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxself.h"
#include "log.h"
#include "dbcache.h"
diff --git a/src/zabbix_server/timer/timer.c b/src/zabbix_server/timer/timer.c
index aec1e485f6a..0c2f4e0d3ff 100644
--- a/src/zabbix_server/timer/timer.c
+++ b/src/zabbix_server/timer/timer.c
@@ -21,7 +21,7 @@
#include "log.h"
#include "dbcache.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxself.h"
#define ZBX_TIMER_DELAY SEC_PER_MIN
diff --git a/src/zabbix_server/trapper/proxydata.c b/src/zabbix_server/trapper/proxydata.c
index 587c2daeefe..eaeb30585df 100644
--- a/src/zabbix_server/trapper/proxydata.c
+++ b/src/zabbix_server/trapper/proxydata.c
@@ -24,7 +24,7 @@
#include "zbxtasks.h"
#include "mutexs.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxcompress.h"
#include "zbxcommshigh.h"
diff --git a/src/zabbix_server/trapper/trapper.c b/src/zabbix_server/trapper/trapper.c
index 9180303552f..e00bb1b207a 100644
--- a/src/zabbix_server/trapper/trapper.c
+++ b/src/zabbix_server/trapper/trapper.c
@@ -26,7 +26,7 @@
#include "nodecommand.h"
#include "proxyconfig.h"
#include "proxydata.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxcrypto.h"
#include "zbxcommshigh.h"
#include "../../libs/zbxserver/zabbix_stats.h"
diff --git a/src/zabbix_server/vmware/vmware.c b/src/zabbix_server/vmware/vmware.c
index cd12e9135c4..6395b5f7f89 100644
--- a/src/zabbix_server/vmware/vmware.c
+++ b/src/zabbix_server/vmware/vmware.c
@@ -25,11 +25,10 @@
#endif
#include "mutexs.h"
-#include "memalloc.h"
+#include "zbxshmem.h"
#include "log.h"
-#include "daemon.h"
+#include "zbxnix.h"
#include "zbxself.h"
-#include "../../libs/zbxalgo/vectorimpl.h"
/*
* The VMware data (zbx_vmware_service_t structure) are stored in shared memory.
@@ -69,8 +68,8 @@ extern unsigned char program_type;
extern ZBX_THREAD_LOCAL int server_num, process_num;
extern char *CONFIG_SOURCE_IP;
-#define VMWARE_VECTOR_CREATE(ref, type) zbx_vector_##type##_create_ext(ref, __vm_mem_malloc_func, \
- __vm_mem_realloc_func, __vm_mem_free_func)
+#define VMWARE_VECTOR_CREATE(ref, type) zbx_vector_##type##_create_ext(ref, __vm_shmem_malloc_func, \
+ __vm_shmem_realloc_func, __vm_shmem_free_func)
#define ZBX_VMWARE_CACHE_UPDATE_PERIOD CONFIG_VMWARE_FREQUENCY
#define ZBX_VMWARE_PERF_UPDATE_PERIOD CONFIG_VMWARE_PERF_FREQUENCY
@@ -83,9 +82,9 @@ extern char *CONFIG_SOURCE_IP;
static zbx_mutex_t vmware_lock = ZBX_MUTEX_NULL;
-static zbx_mem_info_t *vmware_mem = NULL;
+static zbx_shmem_info_t *vmware_mem = NULL;
-ZBX_MEM_FUNC_IMPL(__vm, vmware_mem)
+ZBX_SHMEM_FUNC_IMPL(__vm, vmware_mem)
static zbx_vmware_t *vmware = NULL;
@@ -506,7 +505,7 @@ static char *vmware_shared_strdup(const char *str)
strdup = vmware_strpool_strdup(str, &vmware->strpool, &len);
if (0 < len)
- vmware->strpool_sz += zbx_mem_required_chunk_size(len);
+ vmware->strpool_sz += zbx_shmem_required_chunk_size(len);
return strdup;
}
@@ -537,7 +536,7 @@ static void vmware_shared_strfree(char *str)
vmware_strpool_strfree(str, &vmware->strpool, &len);
if (0 < len)
- vmware->strpool_sz -= zbx_mem_required_chunk_size(len);
+ vmware->strpool_sz -= zbx_shmem_required_chunk_size(len);
}
static void evt_msg_strpool_strfree(char *str)
@@ -898,7 +897,7 @@ static void vmware_perf_counter_shared_free(zbx_vmware_perf_counter_t *counter)
{
vmware_vector_str_uint64_pair_shared_clean(&counter->values);
zbx_vector_str_uint64_pair_destroy(&counter->values);
- __vm_mem_free_func(counter);
+ __vm_shmem_free_func(counter);
}
/******************************************************************************
@@ -940,7 +939,7 @@ static void vmware_diskextent_shared_free(zbx_vmware_diskextent_t *diskextent)
{
vmware_shared_strfree(diskextent->diskname);
- __vm_mem_free_func(diskextent);
+ __vm_shmem_free_func(diskextent);
}
/******************************************************************************
@@ -964,7 +963,7 @@ static void vmware_datastore_shared_free(zbx_vmware_datastore_t *datastore)
zbx_vector_vmware_diskextent_clear_ext(&datastore->diskextents, vmware_diskextent_shared_free);
zbx_vector_vmware_diskextent_destroy(&datastore->diskextents);
- __vm_mem_free_func(datastore);
+ __vm_shmem_free_func(datastore);
}
/******************************************************************************
@@ -979,7 +978,7 @@ static void vmware_datacenter_shared_free(zbx_vmware_datacenter_t *datacenter)
vmware_shared_strfree(datacenter->name);
vmware_shared_strfree(datacenter->id);
- __vm_mem_free_func(datacenter);
+ __vm_shmem_free_func(datacenter);
}
/******************************************************************************
@@ -1003,7 +1002,7 @@ static void vmware_props_shared_free(char **props, int props_num)
vmware_shared_strfree(props[i]);
}
- __vm_mem_free_func(props);
+ __vm_shmem_free_func(props);
}
/******************************************************************************
@@ -1021,7 +1020,7 @@ static void vmware_dev_shared_free(zbx_vmware_dev_t *dev)
if (NULL != dev->label)
vmware_shared_strfree(dev->label);
- __vm_mem_free_func(dev);
+ __vm_shmem_free_func(dev);
}
/******************************************************************************
@@ -1036,7 +1035,7 @@ static void vmware_fs_shared_free(zbx_vmware_fs_t *fs)
if (NULL != fs->path)
vmware_shared_strfree(fs->path);
- __vm_mem_free_func(fs);
+ __vm_shmem_free_func(fs);
}
/******************************************************************************
@@ -1062,7 +1061,7 @@ static void vmware_vm_shared_free(zbx_vmware_vm_t *vm)
vmware_props_shared_free(vm->props, ZBX_VMWARE_VMPROPS_NUM);
- __vm_mem_free_func(vm);
+ __vm_shmem_free_func(vm);
}
/******************************************************************************
@@ -1077,7 +1076,7 @@ static void vmware_dsname_shared_free(zbx_vmware_dsname_t *dsname)
vmware_shared_strfree(dsname->name);
zbx_vector_vmware_hvdisk_destroy(&dsname->hvdisks);
- __vm_mem_free_func(dsname);
+ __vm_shmem_free_func(dsname);
}
/******************************************************************************
@@ -1137,7 +1136,7 @@ static void vmware_cluster_shared_free(zbx_vmware_cluster_t *cluster)
if (NULL != cluster->status)
vmware_shared_strfree(cluster->status);
- __vm_mem_free_func(cluster);
+ __vm_shmem_free_func(cluster);
}
/******************************************************************************
@@ -1152,7 +1151,7 @@ static void vmware_event_shared_free(zbx_vmware_event_t *event)
if (NULL != event->message)
vmware_shared_strfree(event->message);
- __vm_mem_free_func(event);
+ __vm_shmem_free_func(event);
}
/******************************************************************************
@@ -1191,7 +1190,7 @@ static void vmware_data_shared_free(zbx_vmware_data_t *data)
if (NULL != data->error)
vmware_shared_strfree(data->error);
- __vm_mem_free_func(data);
+ __vm_shmem_free_func(data);
}
}
@@ -1265,7 +1264,7 @@ static void vmware_service_shared_free(zbx_vmware_service_t *service)
zbx_hashset_destroy(&service->counters);
- __vm_mem_free_func(service);
+ __vm_shmem_free_func(service);
zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __func__);
}
@@ -1283,7 +1282,7 @@ static zbx_vmware_cluster_t *vmware_cluster_shared_dup(const zbx_vmware_cluster_
{
zbx_vmware_cluster_t *cluster;
- cluster = (zbx_vmware_cluster_t *)__vm_mem_malloc_func(NULL, sizeof(zbx_vmware_cluster_t));
+ cluster = (zbx_vmware_cluster_t *)__vm_shmem_malloc_func(NULL, sizeof(zbx_vmware_cluster_t));
cluster->id = vmware_shared_strdup(src->id);
cluster->name = vmware_shared_strdup(src->name);
cluster->status = vmware_shared_strdup(src->status);
@@ -1304,7 +1303,7 @@ static zbx_vmware_event_t *vmware_event_shared_dup(const zbx_vmware_event_t *src
{
zbx_vmware_event_t *event;
- event = (zbx_vmware_event_t *)__vm_mem_malloc_func(NULL, sizeof(zbx_vmware_event_t));
+ event = (zbx_vmware_event_t *)__vm_shmem_malloc_func(NULL, sizeof(zbx_vmware_event_t));
event->key = src->key;
event->message = vmware_shared_strdup(src->message);
event->timestamp = src->timestamp;
@@ -1325,7 +1324,7 @@ static zbx_vmware_diskextent_t *vmware_diskextent_shared_dup(const zbx_vmware_di
{
zbx_vmware_diskextent_t *diskextent;
- diskextent = (zbx_vmware_diskextent_t *)__vm_mem_malloc_func(NULL, sizeof(zbx_vmware_diskextent_t));
+ diskextent = (zbx_vmware_diskextent_t *)__vm_shmem_malloc_func(NULL, sizeof(zbx_vmware_diskextent_t));
diskextent->diskname = vmware_shared_strdup(src->diskname);
diskextent->partitionid = src->partitionid;
@@ -1346,7 +1345,7 @@ static zbx_vmware_datastore_t *vmware_datastore_shared_dup(const zbx_vmware_data
int i;
zbx_vmware_datastore_t *datastore;
- datastore = (zbx_vmware_datastore_t *)__vm_mem_malloc_func(NULL, sizeof(zbx_vmware_datastore_t));
+ datastore = (zbx_vmware_datastore_t *)__vm_shmem_malloc_func(NULL, sizeof(zbx_vmware_datastore_t));
datastore->uuid = vmware_shared_strdup(src->uuid);
datastore->name = vmware_shared_strdup(src->name);
datastore->id = vmware_shared_strdup(src->id);
@@ -1390,7 +1389,7 @@ static zbx_vmware_datacenter_t *vmware_datacenter_shared_dup(const zbx_vmware_da
{
zbx_vmware_datacenter_t *datacenter;
- datacenter = (zbx_vmware_datacenter_t *)__vm_mem_malloc_func(NULL, sizeof(zbx_vmware_datacenter_t));
+ datacenter = (zbx_vmware_datacenter_t *)__vm_shmem_malloc_func(NULL, sizeof(zbx_vmware_datacenter_t));
datacenter->name = vmware_shared_strdup(src->name);
datacenter->id = vmware_shared_strdup(src->id);
@@ -1410,7 +1409,7 @@ static zbx_vmware_dev_t *vmware_dev_shared_dup(const zbx_vmware_dev_t *src)
{
zbx_vmware_dev_t *dev;
- dev = (zbx_vmware_dev_t *)__vm_mem_malloc_func(NULL, sizeof(zbx_vmware_dev_t));
+ dev = (zbx_vmware_dev_t *)__vm_shmem_malloc_func(NULL, sizeof(zbx_vmware_dev_t));
dev->type = src->type;
dev->instance = vmware_shared_strdup(src->instance);
dev->label = vmware_shared_strdup(src->label);
@@ -1432,7 +1431,7 @@ static zbx_vmware_fs_t *vmware_fs_shared_dup(const zbx_vmware_fs_t *src)
{
zbx_vmware_fs_t *fs;
- fs = (zbx_vmware_fs_t *)__vm_mem_malloc_func(NULL, sizeof(zbx_vmware_fs_t));
+ fs = (zbx_vmware_fs_t *)__vm_shmem_malloc_func(NULL, sizeof(zbx_vmware_fs_t));
fs->path = vmware_shared_strdup(src->path);
fs->capacity = src->capacity;
fs->free_space = src->free_space;
@@ -1455,7 +1454,7 @@ static char **vmware_props_shared_dup(char ** const src, int props_num)
char **props;
int i;
- props = (char **)__vm_mem_malloc_func(NULL, sizeof(char *) * props_num);
+ props = (char **)__vm_shmem_malloc_func(NULL, sizeof(char *) * props_num);
for (i = 0; i < props_num; i++)
props[i] = vmware_shared_strdup(src[i]);
@@ -1477,7 +1476,7 @@ static zbx_vmware_vm_t *vmware_vm_shared_dup(const zbx_vmware_vm_t *src)
zbx_vmware_vm_t *vm;
int i;
- vm = (zbx_vmware_vm_t *)__vm_mem_malloc_func(NULL, sizeof(zbx_vmware_vm_t));
+ vm = (zbx_vmware_vm_t *)__vm_shmem_malloc_func(NULL, sizeof(zbx_vmware_vm_t));
VMWARE_VECTOR_CREATE(&vm->devs, ptr);
VMWARE_VECTOR_CREATE(&vm->file_systems, ptr);
@@ -1511,7 +1510,7 @@ static zbx_vmware_dsname_t *vmware_dsname_shared_dup(const zbx_vmware_dsname_t *
zbx_vmware_dsname_t *dsname;
int i;
- dsname = (zbx_vmware_dsname_t *)__vm_mem_malloc_func(NULL, sizeof(zbx_vmware_dsname_t));
+ dsname = (zbx_vmware_dsname_t *)__vm_shmem_malloc_func(NULL, sizeof(zbx_vmware_dsname_t));
dsname->name = vmware_shared_strdup(src->name);
@@ -1576,9 +1575,9 @@ static zbx_vmware_data_t *vmware_data_shared_dup(zbx_vmware_data_t *src)
zbx_hashset_iter_t iter;
zbx_vmware_hv_t *hv, hv_local;
- data = (zbx_vmware_data_t *)__vm_mem_malloc_func(NULL, sizeof(zbx_vmware_data_t));
- zbx_hashset_create_ext(&data->hvs, 1, vmware_hv_hash, vmware_hv_compare, NULL, __vm_mem_malloc_func,
- __vm_mem_realloc_func, __vm_mem_free_func);
+ data = (zbx_vmware_data_t *)__vm_shmem_malloc_func(NULL, sizeof(zbx_vmware_data_t));
+ zbx_hashset_create_ext(&data->hvs, 1, vmware_hv_hash, vmware_hv_compare, NULL, __vm_shmem_malloc_func,
+ __vm_shmem_realloc_func, __vm_shmem_free_func);
VMWARE_VECTOR_CREATE(&data->clusters, ptr);
VMWARE_VECTOR_CREATE(&data->events, ptr);
VMWARE_VECTOR_CREATE(&data->datastores, vmware_datastore);
@@ -1588,8 +1587,8 @@ static zbx_vmware_data_t *vmware_data_shared_dup(zbx_vmware_data_t *src)
zbx_vector_vmware_datastore_reserve(&data->datastores, src->datastores.values_num);
zbx_vector_vmware_datacenter_reserve(&data->datacenters, src->datacenters.values_num);
- zbx_hashset_create_ext(&data->vms_index, 100, vmware_vm_hash, vmware_vm_compare, NULL, __vm_mem_malloc_func,
- __vm_mem_realloc_func, __vm_mem_free_func);
+ zbx_hashset_create_ext(&data->vms_index, 100, vmware_vm_hash, vmware_vm_compare, NULL, __vm_shmem_malloc_func,
+ __vm_shmem_realloc_func, __vm_shmem_free_func);
data->error = vmware_shared_strdup(src->error);
@@ -4500,7 +4499,7 @@ static int vmware_service_put_event_data(zbx_vector_ptr_t *events, zbx_id_xmlnod
zbx_vector_ptr_append(events, event);
if (0 < sz)
- *alloc_sz += zbx_mem_required_chunk_size(sz);
+ *alloc_sz += zbx_shmem_required_chunk_size(sz);
return SUCCEED;
}
@@ -5244,12 +5243,12 @@ static void vmware_counters_add_new(zbx_vector_ptr_t *counters, zbx_uint64_t cou
{
zbx_vmware_perf_counter_t *counter;
- counter = (zbx_vmware_perf_counter_t *)__vm_mem_malloc_func(NULL, sizeof(zbx_vmware_perf_counter_t));
+ counter = (zbx_vmware_perf_counter_t *)__vm_shmem_malloc_func(NULL, sizeof(zbx_vmware_perf_counter_t));
counter->counterid = counterid;
counter->state = ZBX_VMWARE_COUNTER_NEW;
- zbx_vector_str_uint64_pair_create_ext(&counter->values, __vm_mem_malloc_func, __vm_mem_realloc_func,
- __vm_mem_free_func);
+ zbx_vector_str_uint64_pair_create_ext(&counter->values, __vm_shmem_malloc_func, __vm_shmem_realloc_func,
+ __vm_shmem_free_func);
zbx_vector_ptr_append(counters, counter);
}
@@ -5387,8 +5386,8 @@ static void vmware_service_add_perf_entity(zbx_vmware_service_t *service, const
pentity = (zbx_vmware_perf_entity_t *)zbx_hashset_insert(&service->entities, &entity, sizeof(zbx_vmware_perf_entity_t));
- zbx_vector_ptr_create_ext(&pentity->counters, __vm_mem_malloc_func, __vm_mem_realloc_func,
- __vm_mem_free_func);
+ zbx_vector_ptr_create_ext(&pentity->counters, __vm_shmem_malloc_func, __vm_shmem_realloc_func,
+ __vm_shmem_free_func);
for (i = 0; NULL != counters[i]; i++)
{
@@ -5700,7 +5699,7 @@ out:
service->eventlog.oom = 0;
events_sz += evt_req_chunk_size * data->events.values_num +
- zbx_mem_required_chunk_size(data->events.values_alloc * sizeof(zbx_vmware_event_t*));
+ zbx_shmem_required_chunk_size(data->events.values_alloc * sizeof(zbx_vmware_event_t*));
if (0 == service->eventlog.last_key || vmware_mem->free_size < events_sz ||
SUCCEED == ZBX_CHECK_LOG_LEVEL(LOG_LEVEL_DEBUG))
@@ -5711,7 +5710,7 @@ out:
if (SUCCEED == vmware_shared_strsearch(event->message))
{
- events_sz -= zbx_mem_required_chunk_size(strlen(event->message) +
+ events_sz -= zbx_shmem_required_chunk_size(strlen(event->message) +
REFCOUNT_FIELD_SIZE + 1 + ZBX_HASHSET_ENTRY_OFFSET);
}
}
@@ -5767,7 +5766,7 @@ out:
vmware_service_update_perf_entities(service);
if (SUCCEED == ZBX_CHECK_LOG_LEVEL(LOG_LEVEL_DEBUG))
- zbx_mem_dump_stats(LOG_LEVEL_DEBUG, vmware_mem);
+ zbx_shmem_dump_stats(LOG_LEVEL_DEBUG, vmware_mem);
zbx_snprintf(msg, sizeof(msg), "Events:%d DC:%d DS:%d CL:%d HV:%d VM:%d"
" VMwareCache memory usage (free/strpool/total): " ZBX_FS_UI64 " / " ZBX_FS_UI64 " / "
@@ -6387,7 +6386,7 @@ zbx_vmware_service_t *zbx_vmware_get_service(const char* url, const char* userna
}
}
- service = (zbx_vmware_service_t *)__vm_mem_malloc_func(NULL, sizeof(zbx_vmware_service_t));
+ service = (zbx_vmware_service_t *)__vm_shmem_malloc_func(NULL, sizeof(zbx_vmware_service_t));
memset(service, 0, sizeof(zbx_vmware_service_t));
service->url = vmware_shared_strdup(url);
@@ -6402,11 +6401,11 @@ zbx_vmware_service_t *zbx_vmware_get_service(const char* url, const char* userna
service->eventlog.oom = 0;
zbx_hashset_create_ext(&service->entities, 100, vmware_perf_entity_hash_func, vmware_perf_entity_compare_func,
- NULL, __vm_mem_malloc_func, __vm_mem_realloc_func, __vm_mem_free_func);
+ NULL, __vm_shmem_malloc_func, __vm_shmem_realloc_func, __vm_shmem_free_func);
zbx_hashset_create_ext(&service->counters, ZBX_VMWARE_COUNTERS_INIT_SIZE, vmware_counter_hash_func,
- vmware_counter_compare_func, NULL, __vm_mem_malloc_func, __vm_mem_realloc_func,
- __vm_mem_free_func);
+ vmware_counter_compare_func, NULL, __vm_shmem_malloc_func, __vm_shmem_realloc_func,
+ __vm_shmem_free_func);
zbx_vector_ptr_append(&vmware->services, service);
@@ -6493,8 +6492,8 @@ int zbx_vmware_service_add_perf_counter(zbx_vmware_service_t *service, const cha
entity.type = vmware_shared_strdup(type);
entity.id = vmware_shared_strdup(id);
entity.error = NULL;
- zbx_vector_ptr_create_ext(&entity.counters, __vm_mem_malloc_func, __vm_mem_realloc_func,
- __vm_mem_free_func);
+ zbx_vector_ptr_create_ext(&entity.counters, __vm_shmem_malloc_func, __vm_shmem_realloc_func,
+ __vm_shmem_free_func);
pentity = (zbx_vmware_perf_entity_t *)zbx_hashset_insert(&service->entities, &entity,
sizeof(zbx_vmware_perf_entity_t));
@@ -6556,26 +6555,26 @@ int zbx_vmware_init(char **error)
if (SUCCEED != zbx_mutex_create(&vmware_lock, ZBX_MUTEX_VMWARE, error))
goto out;
- size_reserved = zbx_mem_required_size(1, "vmware cache size", "VMwareCacheSize");
+ size_reserved = zbx_shmem_required_size(1, "vmware cache size", "VMwareCacheSize");
CONFIG_VMWARE_CACHE_SIZE -= size_reserved;
- if (SUCCEED != zbx_mem_create(&vmware_mem, CONFIG_VMWARE_CACHE_SIZE, "vmware cache size", "VMwareCacheSize", 0,
- error))
+ if (SUCCEED != zbx_shmem_create(&vmware_mem, CONFIG_VMWARE_CACHE_SIZE, "vmware cache size", "VMwareCacheSize",
+ 0, error))
{
goto out;
}
- vmware = (zbx_vmware_t *)__vm_mem_malloc_func(NULL, sizeof(zbx_vmware_t));
+ vmware = (zbx_vmware_t *)__vm_shmem_malloc_func(NULL, sizeof(zbx_vmware_t));
memset(vmware, 0, sizeof(zbx_vmware_t));
VMWARE_VECTOR_CREATE(&vmware->services, ptr);
#if defined(HAVE_LIBXML2) && defined(HAVE_LIBCURL)
vmware->strpool_sz = 0;
zbx_hashset_create_ext(&vmware->strpool, 100, vmware_strpool_hash_func, vmware_strpool_compare_func, NULL,
- __vm_mem_malloc_func, __vm_mem_realloc_func, __vm_mem_free_func);
+ __vm_shmem_malloc_func, __vm_shmem_realloc_func, __vm_shmem_free_func);
zbx_hashset_create(&evt_msg_strpool, 100, vmware_strpool_hash_func, vmware_strpool_compare_func);
- evt_req_chunk_size = zbx_mem_required_chunk_size(sizeof(zbx_vmware_event_t));
+ evt_req_chunk_size = zbx_shmem_required_chunk_size(sizeof(zbx_vmware_event_t));
#endif
ret = SUCCEED;
out:
@@ -6598,7 +6597,7 @@ void zbx_vmware_destroy(void)
zbx_hashset_destroy(&vmware->strpool);
zbx_hashset_destroy(&evt_msg_strpool);
#endif
- zbx_mem_destroy(vmware_mem);
+ zbx_shmem_destroy(vmware_mem);
vmware_mem = NULL;
zbx_mutex_destroy(&vmware_lock);
}