Module: check_mk
Branch: master
Commit: 3e8a9cad65353dead209395f0b357f6fe71cfafc
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3e8a9cad65353d…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Wed Dec 6 10:38:36 2017 +0100
Windows agent: use RAII for event handles
More precisely, use the Resource Release is Finalization principle as
the handles cannot be always acquired in a uniform way in a constructor
due to the various ways handles can be acquired/opened through WinAPI.
Wrap handles related to eventlog handling in instances of classes
responsible for releasing the resources (alias closing the handles in
this case). Specialize based wrapper class through handle-specific
traits classes for handle type, invalid value as well as closing the
handle.
Do not wrap wrapper classes further to unique_ptr's etc when. there is no
need for heap allocation of the wrapper object.
Also refactor the eventlog handling in order to get rid of unnecessary
resetting.
Add unit tests for handle wrappers.
Change-Id: Iacd6e245d5e55b6276f3ce3509ea6679103e7e8b
---
agents/windows/EventLog.cc | 92 ++++-----
agents/windows/EventLog.h | 84 ++------
agents/windows/EventLogVista.cc | 184 +++++++++---------
agents/windows/EventLogVista.h | 76 ++------
agents/windows/IEventLog.h | 15 +-
agents/windows/Makefile.am | 3 +
agents/windows/build_version | 2 +-
agents/windows/sections/SectionEventlog.cc | 1 -
agents/windows/test/EnvironmentTest.cc | 3 -
agents/windows/test/EventLogVistaTest.cc | 107 +++++++++++
agents/windows/test/MockWbem.h | 2 +-
agents/windows/test/typesTest.cc | 295 +++++++++++++++++++++++++++++
agents/windows/test/wmiHelperTest.cc | 12 +-
agents/windows/types.h | 122 ++++++++++--
14 files changed, 691 insertions(+), 307 deletions(-)
Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=3e8a9cad65…