1 |
commit: c4f4d3abf675460b53e5ebb9a0550a4c9a539771 |
2 |
Author: Michael Orlitzky <mjo <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Aug 19 23:30:32 2019 +0000 |
4 |
Commit: Michael Orlitzky <mjo <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Aug 19 23:30:56 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c4f4d3ab |
7 |
|
8 |
net-analyzer/nagios-core: new revision fixing zombie process bug. |
9 |
|
10 |
Bug: https://bugs.gentoo.org/692092 |
11 |
Reported-by: Tomáš Mózes <hydrapolic <AT> gmail.com> |
12 |
Package-Manager: Portage-2.3.69, Repoman-2.3.16 |
13 |
Signed-off-by: Michael Orlitzky <mjo <AT> gentoo.org> |
14 |
|
15 |
.../nagios-core-4.4.4-no-zombie-processes.patch | 158 +++++++++++++++++++++ |
16 |
...re-4.4.4.ebuild => nagios-core-4.4.4-r1.ebuild} | 2 + |
17 |
2 files changed, 160 insertions(+) |
18 |
|
19 |
diff --git a/net-analyzer/nagios-core/files/nagios-core-4.4.4-no-zombie-processes.patch b/net-analyzer/nagios-core/files/nagios-core-4.4.4-no-zombie-processes.patch |
20 |
new file mode 100644 |
21 |
index 00000000000..4592b1d27f4 |
22 |
--- /dev/null |
23 |
+++ b/net-analyzer/nagios-core/files/nagios-core-4.4.4-no-zombie-processes.patch |
24 |
@@ -0,0 +1,158 @@ |
25 |
+This was an upstream bug that has been reverted for nagios-core-4.4.5: |
26 |
+ |
27 |
+ https://github.com/NagiosEnterprises/nagioscore/issues/683 |
28 |
+ |
29 |
+Thanks to Tomáš Mózes (hydrapolic) for noticing and reporting the fix. |
30 |
+ |
31 |
+diff --git a/base/events.c b/base/events.c |
32 |
+index d601e970f..bb27b3240 100644 |
33 |
+--- a/base/events.c |
34 |
++++ b/base/events.c |
35 |
+@@ -351,13 +351,12 @@ void init_timing_loop(void) { |
36 |
+ */ |
37 |
+ check_delay = |
38 |
+ mult_factor * scheduling_info.service_inter_check_delay; |
39 |
+- time_t check_window = reschedule_within_timeperiod(next_valid_time, temp_service->check_period_ptr, check_window(temp_service)) - current_time; |
40 |
+- if(check_delay > check_window) { |
41 |
++ if(check_delay > check_window(temp_service)) { |
42 |
+ log_debug_info(DEBUGL_EVENTS, 0, |
43 |
+ " Fixing check time %lu secs too far away\n", |
44 |
+- check_delay - check_window); |
45 |
++ check_delay - check_window(temp_service)); |
46 |
+ fixed_services++; |
47 |
+- check_delay = check_window; |
48 |
++ check_delay = check_window(temp_service); |
49 |
+ log_debug_info(DEBUGL_EVENTS, 0, " New check offset: %d\n", |
50 |
+ check_delay); |
51 |
+ } |
52 |
+@@ -370,7 +369,8 @@ void init_timing_loop(void) { |
53 |
+ if(is_valid_time == ERROR) { |
54 |
+ log_debug_info(DEBUGL_EVENTS, 2, "Preferred Time is Invalid In Timeperiod '%s': %lu --> %s\n", temp_service->check_period_ptr->name, (unsigned long)temp_service->next_check, ctime(&temp_service->next_check)); |
55 |
+ get_next_valid_time(temp_service->next_check, &next_valid_time, temp_service->check_period_ptr); |
56 |
+- temp_service->next_check = reschedule_within_timeperiod(next_valid_time, temp_service->check_period_ptr, check_window(temp_service)); |
57 |
++ temp_service->next_check = |
58 |
++ (time_t)(next_valid_time + check_delay); |
59 |
+ } |
60 |
+ |
61 |
+ log_debug_info(DEBUGL_EVENTS, 2, "Actual Check Time: %lu --> %s\n", (unsigned long)temp_service->next_check, ctime(&temp_service->next_check)); |
62 |
+@@ -508,7 +508,7 @@ void init_timing_loop(void) { |
63 |
+ log_debug_info(DEBUGL_EVENTS, 1, "Fixing check time (off by %lu)\n", |
64 |
+ check_delay - check_window(temp_host)); |
65 |
+ fixed_hosts++; |
66 |
+- check_delay = reschedule_within_timeperiod(next_valid_time, temp_host->check_period_ptr, check_window(temp_host)); |
67 |
++ check_delay = ranged_urand(0, check_window(temp_host)); |
68 |
+ } |
69 |
+ temp_host->next_check = (time_t)(current_time + check_delay); |
70 |
+ |
71 |
+diff --git a/cgi/status.c b/cgi/status.c |
72 |
+index ae723c683..2f6a60fde 100644 |
73 |
+--- a/cgi/status.c |
74 |
++++ b/cgi/status.c |
75 |
+@@ -221,8 +221,26 @@ int main(void) { |
76 |
+ document_header(TRUE); |
77 |
+ |
78 |
+ /* if a navbar search was performed, find the host by name, address or partial name */ |
79 |
+- if(navbar_search == TRUE) { |
80 |
+- if(host_name != NULL && NULL != strstr(host_name, "*")) { |
81 |
++ if(navbar_search == TRUE && host_name != NULL) { |
82 |
++ |
83 |
++ /* Remove trailing spaces from host_name */ |
84 |
++ len = strlen(host_name); |
85 |
++ for (i = len - 1; i >= 0; i--) { |
86 |
++ if (!isspace(host_name[i])) { |
87 |
++ host_name[i+1] = '\0'; |
88 |
++ break; |
89 |
++ } |
90 |
++ } |
91 |
++ |
92 |
++ /* Remove leading spaces from host_name */ |
93 |
++ for (i = 0; i < len; i++) { |
94 |
++ if (!isspace(host_name[i])) { |
95 |
++ break; |
96 |
++ } |
97 |
++ } |
98 |
++ strcpy(host_name, host_name + i); |
99 |
++ |
100 |
++ if(NULL != strstr(host_name, "*")) { |
101 |
+ /* allocate for 3 extra chars, ^, $ and \0 */ |
102 |
+ host_filter = malloc(sizeof(char) * (strlen(host_name) * 2 + 3)); |
103 |
+ len = strlen(host_name); |
104 |
+@@ -238,7 +256,7 @@ int main(void) { |
105 |
+ host_filter[regex_i++] = '$'; |
106 |
+ host_filter[regex_i] = '\0'; |
107 |
+ } |
108 |
+- else if (host_name != NULL) { |
109 |
++ else { |
110 |
+ if((temp_host = find_host(host_name)) == NULL) { |
111 |
+ for(temp_host = host_list; temp_host != NULL; temp_host = temp_host->next) { |
112 |
+ if(is_authorized_for_host(temp_host, ¤t_authdata) == FALSE) |
113 |
+diff --git a/lib/worker.c b/lib/worker.c |
114 |
+index 4f7cbc384..a94719cc4 100644 |
115 |
+--- a/lib/worker.c |
116 |
++++ b/lib/worker.c |
117 |
+@@ -215,7 +215,7 @@ int worker_buf2kvvec_prealloc(struct kvvec *kvv, char *buf, unsigned long len, i |
118 |
+ } while (0) |
119 |
+ |
120 |
+ /* forward declaration */ |
121 |
+-static int gather_output(child_process *cp, iobuf *io, int final); |
122 |
++static void gather_output(child_process *cp, iobuf *io, int final); |
123 |
+ |
124 |
+ static void destroy_job(child_process *cp) |
125 |
+ { |
126 |
+@@ -258,23 +258,15 @@ static void destroy_job(child_process *cp) |
127 |
+ int finish_job(child_process *cp, int reason) |
128 |
+ { |
129 |
+ static struct kvvec resp = KVVEC_INITIALIZER; |
130 |
+- int i, ret, rd; |
131 |
++ int i, ret; |
132 |
+ |
133 |
+ /* get rid of still open filedescriptors */ |
134 |
+ if (cp->outstd.fd != -1) { |
135 |
+- |
136 |
+- rd = 1; |
137 |
+- while(rd > 0) { |
138 |
+- rd = gather_output(cp, &cp->outstd, 0); |
139 |
+- } |
140 |
++ gather_output(cp, &cp->outstd, 1); |
141 |
+ iobroker_close(iobs, cp->outstd.fd); |
142 |
+ } |
143 |
+ if (cp->outerr.fd != -1) { |
144 |
+- |
145 |
+- rd = 1; |
146 |
+- while(rd > 0) { |
147 |
+- rd = gather_output(cp, &cp->outerr, 0); |
148 |
+- } |
149 |
++ gather_output(cp, &cp->outerr, 1); |
150 |
+ iobroker_close(iobs, cp->outerr.fd); |
151 |
+ } |
152 |
+ |
153 |
+@@ -450,13 +442,13 @@ static void kill_job(child_process *cp, int reason) |
154 |
+ destroy_job(cp); |
155 |
+ } |
156 |
+ |
157 |
+-static int gather_output(child_process *cp, iobuf *io, int final) |
158 |
++static void gather_output(child_process *cp, iobuf *io, int final) |
159 |
+ { |
160 |
+ int retry = 5; |
161 |
+- int rd; |
162 |
+ |
163 |
+ for (;;) { |
164 |
+ char buf[4096]; |
165 |
++ int rd; |
166 |
+ |
167 |
+ rd = read(io->fd, buf, sizeof(buf)); |
168 |
+ if (rd < 0) { |
169 |
+@@ -492,13 +484,13 @@ static int gather_output(child_process *cp, iobuf *io, int final) |
170 |
+ if (rd <= 0 || final) { |
171 |
+ iobroker_close(iobs, io->fd); |
172 |
+ io->fd = -1; |
173 |
++ if (!final) |
174 |
++ check_completion(cp, WNOHANG); |
175 |
+ break; |
176 |
+ } |
177 |
+ |
178 |
+ break; |
179 |
+ } |
180 |
+- |
181 |
+- return rd; |
182 |
+ } |
183 |
|
184 |
diff --git a/net-analyzer/nagios-core/nagios-core-4.4.4.ebuild b/net-analyzer/nagios-core/nagios-core-4.4.4-r1.ebuild |
185 |
similarity index 99% |
186 |
rename from net-analyzer/nagios-core/nagios-core-4.4.4.ebuild |
187 |
rename to net-analyzer/nagios-core/nagios-core-4.4.4-r1.ebuild |
188 |
index 74ddb853c43..520b2503a8c 100644 |
189 |
--- a/net-analyzer/nagios-core/nagios-core-4.4.4.ebuild |
190 |
+++ b/net-analyzer/nagios-core/nagios-core-4.4.4-r1.ebuild |
191 |
@@ -70,6 +70,8 @@ RDEPEND="${DEPEND} |
192 |
|
193 |
S="${WORKDIR}/${MY_P}" |
194 |
|
195 |
+PATCHES=( "${FILESDIR}/${P}-no-zombie-processes.patch" ) |
196 |
+ |
197 |
pkg_setup() { |
198 |
enewgroup nagios |
199 |
enewuser nagios -1 /bin/bash /var/nagios/home nagios |