diff options
| author | Ed Tanous <etanous@nvidia.com> | 2026-04-13 21:53:02 +0300 |
|---|---|---|
| committer | Ed Tanous <etanous@nvidia.com> | 2026-04-21 01:36:58 +0300 |
| commit | aa2dfd26a514e063d2b62ec32f562cbcd43a21b4 (patch) | |
| tree | db7dfdf37ebd1b8882349b83e5aa7e803725578e /redfish-core/include/utils | |
| parent | 5803072626187a2cc14bd93962a3899ce1fb4695 (diff) | |
| download | bmcweb-aa2dfd26a514e063d2b62ec32f562cbcd43a21b4.tar.xz | |
Remove static variables
These static variables have the potential to cause reentrancy issues.
In practice, the conditions to cause issues would require someone to
basically write incorrect code, but it makes sense to wrap this into a
state tracker anyway to clean up the code. While we're here, convert to
using std::chrono.
Note, this changes the behavior such that the values produced are now no
longer dependent on timezone. Functionally, Redfish only recently got
the ability to set a timezone, so this is not expected to have any user
facing impact, even though the unit tests need to change.
Tested: RSV Passes
Change-Id: Icb7cff1d289ae23790a5fb1db6604abd73dd68fd
Signed-off-by: Ed Tanous <etanous@nvidia.com>
Diffstat (limited to 'redfish-core/include/utils')
| -rw-r--r-- | redfish-core/include/utils/eventlog_utils.hpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/redfish-core/include/utils/eventlog_utils.hpp b/redfish-core/include/utils/eventlog_utils.hpp index 88b14f5707..0be29f2f4d 100644 --- a/redfish-core/include/utils/eventlog_utils.hpp +++ b/redfish-core/include/utils/eventlog_utils.hpp @@ -32,7 +32,6 @@ #include <cstddef> #include <cstdint> #include <cstdio> -#include <ctime> #include <fstream> #include <iomanip> #include <memory> @@ -339,6 +338,7 @@ inline void handleSystemsAndManagersLogServiceEventLogLogEntryCollection( // Oldest logs are in the last file, so start there and loop // backwards + event_log::UniqueEntryIDState state; for (auto it = redfishLogFiles.rbegin(); it < redfishLogFiles.rend(); it++) { std::ifstream logStream(*it); @@ -351,7 +351,7 @@ inline void handleSystemsAndManagersLogServiceEventLogLogEntryCollection( while (std::getline(logStream, logEntry)) { std::string idStr; - if (!event_log::getUniqueEntryID(logEntry, idStr)) + if (!event_log::getUniqueEntryID(state, logEntry, idStr)) { continue; } @@ -418,6 +418,7 @@ inline void handleSystemsAndManagersLogServiceEventLogEntriesGet( // Oldest logs are in the last file, so start there and loop // backwards + event_log::UniqueEntryIDState state; for (auto it = redfishLogFiles.rbegin(); it < redfishLogFiles.rend(); it++) { std::ifstream logStream(*it); @@ -430,7 +431,7 @@ inline void handleSystemsAndManagersLogServiceEventLogEntriesGet( while (std::getline(logStream, logEntry)) { std::string idStr; - if (!event_log::getUniqueEntryID(logEntry, idStr)) + if (!event_log::getUniqueEntryID(state, logEntry, idStr)) { continue; } |
