Module: check_mk
Branch: master
Commit: 61a69fa84c7cb7db6cfe8abb7d8214b2992280cd
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=61a69fa84c7cb7…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Tue May 9 11:30:38 2017 +0200
4475 FIX Windows Agent: Agent shutdown no longer stalls while plugin is running
The agent did not stop any running plugins when the shutdown command was issued
and waited for their completion. A "net stop check_mk_agent" could fail because
of this behaviour.
The agent updater suffered from this too, because the MSI installer failed to stop the
service in time.
Change-Id: I3ad284ccf9fb6ad9c7dd676b3efa919df60d7fa6
---
.werks/4475 | 12 ++++++++++++
agents/windows/OutputProxy.cc | 1 -
agents/windows/build_version | 2 +-
agents/windows/check_mk_agent-64.exe | Bin 1339392 -> 1339392 bytes
agents/windows/check_mk_agent-64.unstripped.exe | Bin 15811066 -> 15811578 bytes
agents/windows/check_mk_agent-64.unversioned.exe | Bin 1339392 -> 1339392 bytes
agents/windows/check_mk_agent.cc | 4 +++-
agents/windows/check_mk_agent.exe | Bin 1316864 -> 1316864 bytes
agents/windows/check_mk_agent.msi | Bin 2926080 -> 2926080 bytes
agents/windows/check_mk_agent.unstripped.exe | Bin 13671970 -> 13671970 bytes
agents/windows/check_mk_agent.unversioned.exe | Bin 1316864 -> 1316864 bytes
agents/windows/crash.exe | Bin 101624 -> 101624 bytes
agents/windows/install_agent-64.exe | Bin 591608 -> 591609 bytes
agents/windows/install_agent.exe | Bin 589024 -> 589028 bytes
agents/windows/nowin.exe | Bin 103760 -> 103760 bytes
agents/windows/plugins/mk_logwatch.exe | Bin 4555413 -> 4563948 bytes
16 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/.werks/4475 b/.werks/4475
new file mode 100644
index 0000000..366b20e
--- /dev/null
+++ b/.werks/4475
@@ -0,0 +1,12 @@
+Title: Windows Agent: Agent shutdown no longer stalls while plugin is running
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1494321863
+Class: fix
+
+The agent did not stop any running plugins when the shutdown command was issued
+and waited for their completion. A "net stop check_mk_agent" could fail because
of this behaviour.
+The agent updater suffered from this too, because the MSI installer failed to stop the
service in time.
diff --git a/agents/windows/OutputProxy.cc b/agents/windows/OutputProxy.cc
index 8317943..38287ce 100644
--- a/agents/windows/OutputProxy.cc
+++ b/agents/windows/OutputProxy.cc
@@ -76,7 +76,6 @@ void BufferedSocketProxy::output(const char *format, ...) {
_length += written_len;
}
-
void BufferedSocketProxy::writeBinary(const char *buffer, size_t size) {
size_t target_size = _length + size + 1;
if (_buffer.size() < target_size) {
diff --git a/agents/windows/build_version b/agents/windows/build_version
index fd5e1fa..4633262 100644
--- a/agents/windows/build_version
+++ b/agents/windows/build_version
@@ -1 +1 @@
-2659
+2663
diff --git a/agents/windows/check_mk_agent-64.exe b/agents/windows/check_mk_agent-64.exe
index be87804..d3a9573 100755
Binary files a/agents/windows/check_mk_agent-64.exe and
b/agents/windows/check_mk_agent-64.exe differ
diff --git a/agents/windows/check_mk_agent-64.unstripped.exe
b/agents/windows/check_mk_agent-64.unstripped.exe
index 177b4a9..0891779 100755
Binary files a/agents/windows/check_mk_agent-64.unstripped.exe and
b/agents/windows/check_mk_agent-64.unstripped.exe differ
diff --git a/agents/windows/check_mk_agent-64.unversioned.exe
b/agents/windows/check_mk_agent-64.unversioned.exe
index 59030a6..0a9551c 100755
Binary files a/agents/windows/check_mk_agent-64.unversioned.exe and
b/agents/windows/check_mk_agent-64.unversioned.exe differ
diff --git a/agents/windows/check_mk_agent.cc b/agents/windows/check_mk_agent.cc
index b56b7be..5654756 100644
--- a/agents/windows/check_mk_agent.cc
+++ b/agents/windows/check_mk_agent.cc
@@ -239,6 +239,7 @@ void foreach_enabled_section(bool realtime,
TCHAR *gszServiceName = (TCHAR *)TEXT(SERVICE_NAME);
SERVICE_STATUS serviceStatus;
SERVICE_STATUS_HANDLE serviceStatusHandle = 0;
+void stop_threads();
void WINAPI ServiceControlHandler(DWORD controlCode) {
switch (controlCode) {
@@ -248,6 +249,7 @@ void WINAPI ServiceControlHandler(DWORD controlCode) {
case SERVICE_CONTROL_SHUTDOWN:
case SERVICE_CONTROL_STOP:
g_should_terminate = true;
+ stop_threads();
serviceStatus.dwCurrentState = SERVICE_STOP_PENDING;
SetServiceStatus(serviceStatusHandle, &serviceStatus);
return;
@@ -429,7 +431,7 @@ void stop_threads() {
// just check the script_container status
foreach_enabled_section(false, [&thread_handles](Section *section) {
std::vector<HANDLE> temp = section->stopAsync();
- thread_handles.insert(temp.begin(), temp.end(), thread_handles.end());
+ thread_handles.insert(thread_handles.end(), temp.begin(), temp.end());
});
WaitForMultipleObjects(thread_handles.size(), &thread_handles[0], TRUE,
diff --git a/agents/windows/check_mk_agent.exe b/agents/windows/check_mk_agent.exe
index cc0a487..1f699ac 100755
Binary files a/agents/windows/check_mk_agent.exe and b/agents/windows/check_mk_agent.exe
differ
diff --git a/agents/windows/check_mk_agent.msi b/agents/windows/check_mk_agent.msi
index 2435328..a7a3f27 100755
Binary files a/agents/windows/check_mk_agent.msi and b/agents/windows/check_mk_agent.msi
differ
diff --git a/agents/windows/check_mk_agent.unstripped.exe
b/agents/windows/check_mk_agent.unstripped.exe
index bf42672..b0da6dc 100755
Binary files a/agents/windows/check_mk_agent.unstripped.exe and
b/agents/windows/check_mk_agent.unstripped.exe differ
diff --git a/agents/windows/check_mk_agent.unversioned.exe
b/agents/windows/check_mk_agent.unversioned.exe
index bfd2bdb..10251ff 100755
Binary files a/agents/windows/check_mk_agent.unversioned.exe and
b/agents/windows/check_mk_agent.unversioned.exe differ
diff --git a/agents/windows/crash.exe b/agents/windows/crash.exe
index 8892763..c40e5e5 100755
Binary files a/agents/windows/crash.exe and b/agents/windows/crash.exe differ
diff --git a/agents/windows/install_agent-64.exe b/agents/windows/install_agent-64.exe
index 3a9fa82..41eb2d7 100755
Binary files a/agents/windows/install_agent-64.exe and
b/agents/windows/install_agent-64.exe differ
diff --git a/agents/windows/install_agent.exe b/agents/windows/install_agent.exe
index 7967a77..030b11e 100755
Binary files a/agents/windows/install_agent.exe and b/agents/windows/install_agent.exe
differ
diff --git a/agents/windows/nowin.exe b/agents/windows/nowin.exe
index 5932127..7d41981 100755
Binary files a/agents/windows/nowin.exe and b/agents/windows/nowin.exe differ
diff --git a/agents/windows/plugins/mk_logwatch.exe
b/agents/windows/plugins/mk_logwatch.exe
index 1f18d82..8d1119b 100755
Binary files a/agents/windows/plugins/mk_logwatch.exe and
b/agents/windows/plugins/mk_logwatch.exe differ