Module: check_mk
Branch: master
Commit: 3eeb2cc1ef0355ca6b0e42056ac1b0b741f9e8b6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3eeb2cc1ef0355…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Tue Feb 23 11:24:22 2016 +0100
#3234 FIX Make unixcat more robust
Previously it could happen that unixcat crashed when system resources and/or
limits were low, especially the nproc limit. Now we emit sensible error
messages and exit with new return codes (5 and 6).
---
.werks/3234 | 13 +++++++++++++
ChangeLog | 1 +
livestatus/src/unixcat.c | 18 ++++++++++++++----
3 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/.werks/3234 b/.werks/3234
new file mode 100644
index 0000000..39669e1
--- /dev/null
+++ b/.werks/3234
@@ -0,0 +1,13 @@
+Title: Make unixcat more robust
+Level: 1
+Component: core
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1456222762
+
+Previously it could happen that unixcat crashed when system resources and/or
+limits were low, especially the nproc limit. Now we emit sensible error
+messages and exit with new return codes (5 and 6).
+
diff --git a/ChangeLog b/ChangeLog
index 25e6ecc..4a1485c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@
* 3214 FIX: Removing SNMP checks for non SNMP hosts and agent based checks for non
agent hosts...
* 3220 FIX: Check_MK HW/SW Inventory is now always disabled for "No Agent"
hosts
* 3221 FIX: Fixed broken nagios config because of missing contact group
check-mk-notify with rule based notifications enabled...
+ * 3234 FIX: Make unixcat more robust...
Checks & Agents:
* 3183 aruba_wlc_aps: new check which monitors the provisioned accesspoints of an
Aruba Network WLAN Controller
diff --git a/livestatus/src/unixcat.c b/livestatus/src/unixcat.c
index a407d43..a3ccfd4 100644
--- a/livestatus/src/unixcat.c
+++ b/livestatus/src/unixcat.c
@@ -160,10 +160,20 @@ int main(int argc, char **argv) {
struct thread_info toleft_info = {sock, 1, 0, 1};
struct thread_info toright_info = {0, sock, 1, 0};
pthread_t toright_thread, toleft_thread;
- pthread_create(&toright_thread, 0, copy_thread, (void *)&toright_info);
- pthread_create(&toleft_thread, 0, copy_thread, (void *)&toleft_info);
- pthread_join(toleft_thread, NULL);
- pthread_join(toright_thread, NULL);
+ if (pthread_create(&toright_thread, 0, copy_thread,
+ (void *)&toright_info) != 0 ||
+ pthread_create(&toleft_thread, 0, copy_thread, (void *)&toleft_info) !=
+ 0) {
+ fprintf(stderr, "Couldn't create threads: %s.\n",
strerror(errno));
+ close(sock);
+ exit(5);
+ }
+ if (pthread_join(toleft_thread, NULL) != 0 ||
+ pthread_join(toright_thread, NULL) != 0) {
+ fprintf(stderr, "Couldn't join threads: %s.\n", strerror(errno));
+ close(sock);
+ exit(6);
+ }
close(sock);
return 0;