Skip to content

Commit

Permalink
fix: On windows, don't cache system is not 64 bits for the service li…
Browse files Browse the repository at this point in the history
…fetime
  • Loading branch information
g-bougard committed Feb 3, 2025
1 parent 6c515f9 commit 56f0f81
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ Revision history for GLPI agent

1.13 not yet released

inventory:
* On windows, don't cache system is not 64 bits for the service lifetime as this can
be the result of a failed WMI call at the service start.

netdiscovery/netinventory:
* PR #836 from @eduardomozart: Enhanced HP wireless printers by reporting wifi ports
as wireless
Expand Down
10 changes: 9 additions & 1 deletion lib/GLPI/Agent/Tools/Win32.pm
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,18 @@ our @EXPORT = qw(
);

my $_is64bits = undef;
my $_is64bits_expiration;
my $_is64bits_nextcheck = 1;
sub is64bit {
# Cache is64bit() result in a private module variable to avoid a lot of wmi
# calls and as this value won't change during the service/task lifetime
return $_is64bits if defined($_is64bits);
# Anyway we make the cached value expirable if we didn't detected it as 64bits
# and in the case WMI request failed. This guaranty to retry the request and not
# cache a wrong value for the service lifetime in some rare cases.
return $_is64bits if $_is64bits ||
($_is64bits_expiration && time < $_is64bits_expiration);
$_is64bits_expiration = time + $_is64bits_nextcheck;
$_is64bits_nextcheck = $_is64bits_nextcheck >= 2000 ? 3600 : $_is64bits_nextcheck * 2;
return $_is64bits =
any { $_->{AddressWidth} eq 64 }
getWMIObjects(
Expand Down

0 comments on commit 56f0f81

Please sign in to comment.