[ZBX-17558] Zabbix agent2 compilation fails on windows Created: 2020 Apr 07  Updated: 2024 Apr 10  Resolved: 2020 Apr 14

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Agent (G)
Affects Version/s: 4.4.7, 5.0.0alpha4
Fix Version/s: 4.4.8rc1, 5.0.0beta1, 5.0 (plan)

Type: Problem report Priority: Trivial
Reporter: Vladislavs Sokurenko Assignee: Vladislavs Sokurenko
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Causes
caused by ZBX-9387 Incorrect maintenance calculations on... Closed
Team: Team A
Sprint: Sprint 63 (Apr 2020)
Story Points: 0.25

 Description   
gcc  -O2 -g -DUNICODE -DHAVE_STDINT_H=1 -Ic:\Users\malloc\Documents\zabbix\build\mingw\..\..\build\win32\include -Ic:\Users\malloc\Documents\zabbix\build\mingw\..\..\build\mingw -Ic:\Users\malloc\Documents\zabbix\build\mingw\..\..\include -DHAVE_OPENSSL=1 -DHAVE_OPENSSL_WITH_PSK=1 -Ic:\dev\openssl\include -Ic:\dev\pcre\include -c c:\Users\malloc\Documents\zabbix\build\mingw\..\..\src\libs\zbxcommon\misc.c -o output\misc.o
c:\Users\malloc\Documents\zabbix\build\mingw\..\..\src\libs\zbxcommon\misc.c: In function 'zbx_get_time':
c:\Users\malloc\Documents\zabbix\build\mingw\..\..\src\libs\zbxcommon\misc.c:368:48: error: 'struct __timeb64' has no member named 'tv_sec'
   offset = zbx_get_timezone_offset(current_time.tv_sec, tm);
                                                ^
c:\Users\malloc\Documents\zabbix\build\mingw\..\..\src\libs\zbxcommon\misc.c: In function 'zbx_get_timezone_offset':
c:\Users\malloc\Documents\zabbix\build\mingw\..\..\src\libs\zbxcommon\misc.c:404:2: warning: implicit declaration of function 'gmtime_r'; did you mean 'gmtime_s'? [-Wimplicit-function-declaration]
  gmtime_r(&t, &tm_utc);
  ^~~~~~~~
  gmtime_s
mingw32-make: *** [Makefile:81: output\misc.o] Error 1

fix:

diff --git a/src/go/internal/agent/scheduler/client.go b/src/go/internal/agent/scheduler/client.go
index bf49442eec..38727ae639 100644
--- a/src/go/internal/agent/scheduler/client.go
+++ b/src/go/internal/agent/scheduler/client.go
@@ -292,7 +292,7 @@ func (c *client) cleanup(plugins map[string]*pluginAgent, now time.Time) (releas
        }

        var expiry time.Time
-       // Direct requests are handled by special clients with id <= ActiveChecksClientID.
+       // Direct requests are handled by special clients with id <= MaxBuiltinClientID.
        // Such requests have day+hour (to keep once per day checks without expiring)
        // expiry time before used plugins are released.
        if c.id > agent.MaxBuiltinClientID {
diff --git a/src/go/plugins/windows/eventlog/eventlog_windows.go b/src/go/plugins/windows/eventlog/eventlog_windows.go
index 95a6b248b1..ef0ffe9aea 100644
--- a/src/go/plugins/windows/eventlog/eventlog_windows.go
+++ b/src/go/plugins/windows/eventlog/eventlog_windows.go
@@ -64,7 +64,7 @@ func (p *Plugin) Validate(options interface{}) error {
 }

 func (p *Plugin) Export(key string, params []string, ctx plugin.ContextProvider) (result interface{}, err error) {
-       if ctx == nil || ctx.ClientID() <= agent.ActiveChecksClientID {
+       if ctx == nil || ctx.ClientID() <= agent.MaxBuiltinClientID {
                return nil, fmt.Errorf(`The "%s" key is not supported in test or single passive check mode`, key)
        }
        meta := ctx.Meta()
diff --git a/src/libs/zbxcommon/misc.c b/src/libs/zbxcommon/misc.c
index 43e7819bfa..e17da86cb0 100644
--- a/src/libs/zbxcommon/misc.c
+++ b/src/libs/zbxcommon/misc.c
@@ -362,7 +362,7 @@ void        zbx_get_time(struct tm *tm, long *milliseconds, zbx_timezone_t *tz)
        if (NULL != tz)
        {
                long    offset;
-#ifdef _WINDOWS
+#if defined(_WINDOWS) || defined(__MINGW32__)
                offset = zbx_get_timezone_offset(current_time.time, tm);
 #else
                offset = zbx_get_timezone_offset(current_time.tv_sec, tm);
@@ -398,7 +398,7 @@ long        zbx_get_timezone_offset(time_t t, struct tm *tm)
 #ifdef HAVE_TM_TM_GMTOFF
        offset = tm->tm_gmtoff;
 #else
-#ifdef _WINDOWS
+#if defined(_WINDOWS) || defined(__MINGW32__)
        tm_utc = *gmtime(&t);
 #else
        gmtime_r(&t, &tm_utc);


 Comments   
Comment by Vladislavs Sokurenko [ 2020 Apr 09 ]

Fixed in:

  • pre-4.4.8rc1 381d4c50f1c
  • pre-5.0.0alpha5 (master) 2623858ddd3
Generated at Tue May 20 08:39:48 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.