Page 1 of 1

[Nagios-devel] [PATCH 4/5] lib/worker: Create pqueue event before

Posted: Mon Nov 05, 2012 1:59 pm
by Guest
From: Robin Sonefors

It's quite possible to build a worker so that it doesn't have to work
asynchronously (or can work very, very, very fast), so that it will call
finish_job before we've finished setting up the child process, which
will cause random memory access errors that can cause worker crashes.
By finishing setup before handing over control to the worker callback,
we can close that possibility.

Signed-off-by: Robin Sonefors
---
lib/worker.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/worker.c b/lib/worker.c
index c7d6de4..7fb6d59 100644
--- a/lib/worker.c
+++ b/lib/worker.c
@@ -532,14 +532,16 @@ static void spawn_job(struct kvvec *kvv, int(*cb)(child_process *))

gettimeofday(&cp->ei->start, NULL);
cp->request = kvv;
+ cp->ei->sq_event = squeue_add(sq, cp->timeout + time(NULL), cp);
+ started++;
+ running_jobs++;
result = cb(cp);
if (result ei->sq_event);
+ running_jobs--;
return;
}
- cp->ei->sq_event = squeue_add(sq, cp->timeout + time(NULL), cp);
- started++;
- running_jobs++;
}

static int receive_command(int sd, int events, void *arg)
--
1.7.11.7






This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]