lib/worker: Change delimiter so it doesn't clash with kvvec:PAIRSEP

Since kvvec:PAIRSEP is a nul byte (as all values must be C strings),
we run an unnecessary amount of memchr() calls for each worker
result we get back (and send).

We switch it to use "\1\0\0\0" instead (a nice 32-bit thing), which
we now have to copy explicitly to the end of the kvv-buffer.

Considering the fact that ascii code 1 is a non-printable character
and therefore should be highly unusual in any normal output sequence,
it should be pretty safe to use this.

An estimate is that we gain at least 10-15% performance from this
small change alone. Quite neat.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2316 5f96b256-904b-4d8d-8c98-d829582c6739
wp-phash: Make this a bit more robust

Since we now support random workers phoning in, it's a good
idea to not crash when we get random strings fed to us where
the chars we care about happen to be outside the range we
supported earlier.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2317 5f96b256-904b-4d8d-8c98-d829582c6739
lib/nsock: Add nsock_printf_nul() as a separate function

The earlier nsock_printf() function would always nul-terminate its
strings, making it pretty hard to create strings that aren't meant
to end with a nul byte.

With this patch, that becomes positively trivial, and adding the
nul byte gets about four typed bytes trickier. None of the previous
callers need to be updated to use the new function.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2318 5f96b256-904b-4d8d-8c98-d829582c6739
lib/wproc: Use more than one worker

With only one, we can't test if workers are being cycled or not.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2319 5f96b256-904b-4d8d-8c98-d829582c6739
base/workers: Rename worker query handler address @wproc

This makes it palatable and easy to add more commands at the @wproc
address other than "register". Since we'll almost certainly want to
add "status" and other debug commands there, this gives us a chance
to do that without cluttering up the queryhandler namespace.

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

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

This makes it dead-simple to build a worker that does exactly what the
internal workers do, which could be used as a convenient starting point
for building more complicated things.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2321 5f96b256-904b-4d8d-8c98-d829582c6739
base/workers: reschedule all worker jobs when worker dies

This also re-joins the worker socket handling code for internal and
external workers - they both need cleanup.

Note: We still don't re-spawn internal workers when they die, which
could cause "funny" results.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2322 5f96b256-904b-4d8d-8c98-d829582c6739
base/workers: Make it possible to register global external workers

That is, external workers that shares the load for any commands, just
like the internal workers.

This means we can now create a watchdog that spawns new external workers
if the original ones crashes or goes away somehow.

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

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

This one will connect to a nagios process and run checks; nothing more,
nothing less.

In other words, we can use this as a replacement for built-in worker
processes, as well as show that it's possible to write external ones.

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

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