[Nagios-devel] [PATCH] base/workers: Write only to initialized

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] [PATCH] base/workers: Write only to initialized

Post by Guest »

From: Robin Sonefors

get_job_id returns -1 when there are no free slots in the worker. We
didn't handle this case with anything other than a comment - the end
result is that the nagios core will assign the -1 slot of the worker,
causing memory errors.

This seems to be what sometimes created crashes when shutting
down/restarting the process. While I haven't been able to create a
completely reproducible test case, I have a fairly large, completely
unrelated test suite that used to cause a crash roughly 1/2 the time it
was executed, and this patched stopped that.

The FIXME to figure out somewhere else to put the check is still in its
place - I still don't do that - but not dumping core because we've got a
sizable workload seems reasonable. It's unlikely that another worker is
available to spread the workload for us, so the error returned about us
being too busy to do anything should normally already be quite
indirectly noticable anyway.

Signed-off-by: Robin Sonefors
---
base/workers.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/base/workers.c b/base/workers.c
index 5338558..9f9aecd 100644
--- a/base/workers.c
+++ b/base/workers.c
@@ -830,8 +830,9 @@ static worker_process *get_worker(worker_job *job)

if (job->id jobs[job->id % wp->max_jobs] = job;
+ wp->jobs[job->id] = job;
job->wp = wp;
return wp;

--
1.7.11.7






This post was automatically imported from historical nagios-devel mailing list archives
Original poster: robin.sonefors@op5.com
Locked