xodtemplate: Fix obscure crash while loading configuration

We didn't initialize parent_map, meaning that it could have any value,
even though it appears it is not infrequently NULL, at least at first.

We then pointed it to a bitmap object iff
xodtemplate_servicedependency_list wasn't NULL, and finally freed it
unconditionally.

Thus, unless parent_map pointed at NULL or we have servicedependencies,
we'd get a crash.

Now, if we first add at least one servicedependency, run nagios, remove
all of them, and reload nagios, parent_map would still keep its old
value around, we wouldn't reallocate it, but we'd still free it, leading
to a crash.

This is prevented in the following ways:
 * First, make sure all bitmaps are NULL-initialized, clearly and
   obviously.
 * Second, only free parent_map if we did set it.
 * Third, set parent_map to NULL after we destroy() it - dangling
   pointers are evil.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2475 5f96b256-904b-4d8d-8c98-d829582c6739
lib/iobroker: Only close fds we're managing

In all places except one, iobroker makes sure it only touches the file
descriptors that's been registered with it. The last place is in the
destructor, which is called quite early in the nagios shutdown process,
making it impossible to log anything else after this.

This patch excludes any valid fds we're not supposed to do anything
with, meaning that, say, stdout won't get mercilessly closed.

In practice, without this patch, a restart would log any broker modules
being unloaded, while a shutdown wouldn't. With this patch, shutdowns do
log broker modules being unloaded.

Reported-by: Anton Löfgren <alofgren@op5.com>
Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2476 5f96b256-904b-4d8d-8c98-d829582c6739
log message when {host,service} check fails

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2477 5f96b256-904b-4d8d-8c98-d829582c6739
Return early when we fail to create_job()

There's no point continuing if we run out of memory to spawn a job,
so we might as well get away early.

Patched-by: Ricardo Jose Maraschini <ricardo.maraschini@opservices.com.br>
Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2478 5f96b256-904b-4d8d-8c98-d829582c6739
base/commands: Log what went wrong when cmd worker failed to launch

The functionality to do so is right there, and the value of this
information is relatively high, so please print it.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2479 5f96b256-904b-4d8d-8c98-d829582c6739
base/workers: Protect against allocation errors in the right places

In a recent patch we added a half-assed protection against memory
allocation errors by protecting against failure to allocate memory
for object check jobs.

This patch removes that particular check and replaces it with a
few others that are more general in nature and will prevent us
from accessing illegal memory no matter where or how allocation
misfires. It is an expanded derivative of a patch sent in by
Ricardo Maraschini, who drew my attention to the matter.

Hinted-at-by: Ricardo Maraschini <ricardo.maraschini@opservices.com.br>
Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2480 5f96b256-904b-4d8d-8c98-d829582c6739
core worker: Remove hard-coded limit of max_jobs=20

Debug remnant, killing performance as surely as poking a kitten
in the face with a lightsaber. Good thing I found this before
christmas, or Santa would surely have revoked my present
privileges.

Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2481 5f96b256-904b-4d8d-8c98-d829582c6739
base/workers: Log why we fail to run checks

The fact that we fail is all good and well, but the why is at least
as important, so make sure we print it for (nearly) all cases.

Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2482 5f96b256-904b-4d8d-8c98-d829582c6739