diff options
author | Michael Veksler <Mihails.Vekslers@zabbix.com> | 2018-02-27 11:39:13 +0300 |
---|---|---|
committer | Michael Veksler <Mihails.Vekslers@zabbix.com> | 2018-02-27 11:39:13 +0300 |
commit | c659fa9892234e2bbead0f72de40de8773238e57 (patch) | |
tree | cb8c1f3d76198f5accd22858b44c3dcaf1e3b1b8 | |
parent | 54e9a8b43d9415b563f9ae70615cab6b2ac05e4b (diff) |
.......... [ZBX-13062] updated to the latest trunk
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | include/sysinfo.h | 7 | ||||
-rw-r--r-- | src/libs/zbxlog/log.c | 13 | ||||
-rw-r--r-- | src/libs/zbxsys/mutexs.c | 11 | ||||
-rw-r--r-- | src/libs/zbxsysinfo/sysinfo.c | 12 |
5 files changed, 45 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog index 9754cfc854d..542d9bdc3bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ Changes for 4.0.0alpha5 New features: Bug fixes: +...G...... [ZBX-13062] banned using of mutex in threads of metrics collection (MVekslers) ........S. [ZBX-13236] fixed error message of function parameters parse (MVekslers) ....I..... [ZBX-10433] removed inaccurate configuration default values (viktors) ....I..... [ZBX-13398] fixed configure script for Debian GNU/Linux "buster" and "sid" to work with PostgreSQL (viktors) @@ -150,6 +151,7 @@ Changes for 3.4.8rc1 New features: Bug fixes: +...G...... [ZBX-13062] banned using of mutex in threads of metrics collection (MVekslers) ....I..... [ZBX-13398] fixed configure script for Debian GNU/Linux "buster" and "sid" to work with PostgreSQL (viktors) ..F....... [ZBX-13428] fixed long name of map outside go back button in map widget (agriscenko, Sasha) A.F....... [ZBX-12754] fixed undefined index error in map import (gcalenko) @@ -1265,6 +1267,7 @@ Changes for 3.0.16rc1 New features: Bug fixes: +...G...... [ZBX-13062] banned using of mutex in threads of metrics collection (MVekslers) -------------------------------------------------------------------------------- Changes for 3.0.15 diff --git a/include/sysinfo.h b/include/sysinfo.h index 6ea5f08dea1..a03d332f3f3 100644 --- a/include/sysinfo.h +++ b/include/sysinfo.h @@ -303,4 +303,11 @@ int zbx_execute_threaded_metric(zbx_metric_func_t metric_func, AGENT_REQUEST *re #define ZBX_SYSINFO_PROC_CMDLINE 0x0004 #define ZBX_SYSINFO_PROC_USER 0x0008 +#ifdef _WINDOWS +#define ZBX_MUTEX_ALL_ALLOW 0 +#define ZBX_MUTEX_THREAD_DENIED 1 +#define ZBX_MUTEX_LOGGING_DENIED 2 +zbx_uint32_t get_thread_global_mutex_flag(); +#endif + #endif diff --git a/src/libs/zbxlog/log.c b/src/libs/zbxlog/log.c index e55abe7b3ae..a97479f4766 100644 --- a/src/libs/zbxlog/log.c +++ b/src/libs/zbxlog/log.c @@ -25,6 +25,7 @@ #ifdef _WINDOWS # include "messages.h" # include "service.h" +# include "sysinfo.h" static HANDLE system_log_handle = INVALID_HANDLE_VALUE; #endif @@ -252,6 +253,18 @@ static void unlock_log(void) if (0 > sigprocmask(SIG_SETMASK, &orig_mask, NULL)) zbx_error("cannot restore sigprocmask"); } +#else +static void lock_log(void) +{ + if (0 == (ZBX_MUTEX_LOGGING_DENIED & get_thread_global_mutex_flag())) + LOCK_LOG; +} + +static void unlock_log(void) +{ + if (0 == (ZBX_MUTEX_LOGGING_DENIED & get_thread_global_mutex_flag())) + UNLOCK_LOG; +} #endif void zbx_handle_log(void) diff --git a/src/libs/zbxsys/mutexs.c b/src/libs/zbxsys/mutexs.c index a55744c1992..924a60a722f 100644 --- a/src/libs/zbxsys/mutexs.c +++ b/src/libs/zbxsys/mutexs.c @@ -21,6 +21,10 @@ #include "log.h" #include "mutexs.h" +#ifdef _WINDOWS +# include "sysinfo.h" +#endif + #ifndef _WINDOWS # if !HAVE_SEMUN union semun @@ -125,6 +129,13 @@ void __zbx_mutex_lock(const char *filename, int line, ZBX_MUTEX *mutex) return; #ifdef _WINDOWS + if (0 != (ZBX_MUTEX_THREAD_DENIED & get_thread_global_mutex_flag())) + { + zbx_error("[file:'%s',line:%d] lock failed: ZBX_MUTEX_THREAD_DENIED is set for thread with id = %d", + filename, line, zbx_get_thread_id()); + exit(EXIT_FAILURE); + } + dwWaitResult = WaitForSingleObject(*mutex, INFINITE); switch (dwWaitResult) diff --git a/src/libs/zbxsysinfo/sysinfo.c b/src/libs/zbxsysinfo/sysinfo.c index 67d62883061..1781a945a65 100644 --- a/src/libs/zbxsysinfo/sysinfo.c +++ b/src/libs/zbxsysinfo/sysinfo.c @@ -1352,11 +1352,19 @@ out: } #else +ZBX_THREAD_LOCAL static zbx_uint32_t mutex_flag = ZBX_MUTEX_ALL_ALLOW; + +zbx_uint32_t get_thread_global_mutex_flag() +{ + return mutex_flag; +} + typedef struct { zbx_metric_func_t func; AGENT_REQUEST *request; AGENT_RESULT *result; + zbx_uint32_t mutex_flag; /* in regular case should always be = ZBX_MUTEX_ALL_ALLOW */ int agent_ret; } zbx_metric_thread_args_t; @@ -1364,6 +1372,7 @@ zbx_metric_thread_args_t; ZBX_THREAD_ENTRY(agent_metric_thread, data) { zbx_metric_thread_args_t *args = (zbx_metric_thread_args_t *)((zbx_thread_args_t *)data)->args; + mutex_flag = args->mutex_flag; zabbix_log(LOG_LEVEL_DEBUG, "executing in data thread for key:'%s'", args->request->key); @@ -1397,7 +1406,8 @@ int zbx_execute_threaded_metric(zbx_metric_func_t metric_func, AGENT_REQUEST *re ZBX_THREAD_HANDLE thread; zbx_thread_args_t args; - zbx_metric_thread_args_t metric_args = {metric_func, request, result}; + zbx_metric_thread_args_t metric_args = {metric_func, request, result, ZBX_MUTEX_THREAD_DENIED | + ZBX_MUTEX_LOGGING_DENIED}; DWORD rc; zabbix_log(LOG_LEVEL_DEBUG, "In %s() key:'%s'", __function_name, request->key); |