t-utils: Always print failed tests

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/t-utils: Make tests verboseable through environment variables

TEST_VERBOSE=1 ./test-kvvec now prints all successful tests. We
set t_verbose if it is so we only ever do the getenv() call once.

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/kvvec: Parse last key/value pair even if it lacks a pair separator

The idiom "foo=lala;bar=hoopla;toodles=banana" makes a lot of sense
for passing data between variables, but we used to miss the last
variable in the key/value vector library if it didn't have a pair
separator.

With this patch the last variable is included iff it's the very
last one *AND* we've already found the (non-optional) key/value
separator (the equal sign '=' in any sane application), which
makes the above idiom work as intended.

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/test-kvvec: Test the new behaviour for kvvec library

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/worker: Kill off all children when we exit

In large (as in, really large) networks, we can easily leave
thousands of processes behind when we're about to reload. That's
pretty bad form and means a ton of processes will contend with
the new processes for cpu time, meaning we can get loadspikes in
the thousands. Not very nice.

Instead we consolidate the worker exiting stuff and make sure we
kill (and reap) our children before we exit properly from the
workers.

Signed-off-by: Andreas Ericsson <ae@op5.se>
query-handler: Print error messages with appended nul byte

It's our sort of official protocol, so we should adhere to it.

Signed-off-by: Andreas Ericsson <ae@op5.se>
query-handler: Enforce the space character

We really don't want a bazillion different query handlers, and this
should discourage the one-query-only handlers from registering with
us. They still can, but queries to them will have to look like so:
  @somewhere<sp><nul>

which has a very shoddy feel about it and will hopefully cause an
infinite amount of shame and grief to fall on the House Of The
Offender.

Signed-off-by: Andreas Ericsson <ae@op5.se>
query-handler: Strip trailing newlines on inbound queries

Most tools that debug and/or use it will want to take user strings,
which will undoubtedly have trailing newlines in the output more
often than not. We get rid of them here so it's all done in one
place with well-exercised code.

Signed-off-by: Andreas Ericsson <ae@op5.se>
query-handler: Disconnect on "query handler not found"

It's an error like any other, so this makes us internall consistent.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Take the @core query handler address

It doesn't do anything yet, but we most certainly don't want anyone
else to snag it, so we mark it as reserved right here and now.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Log incoming worker registration requests

In order to do this (easily), we must change the kv pair separator
so we can log the whole thing as a single line. We do this by using
';' instead of '\n' and log the raw request as and when it comes in.

While at it, we also add error logging for when registration fails
and plug a microscopic leak of sizeof(worker_process) when we fail
to parse the request.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Let workers tell us how many jobs they can run

It's quite likely that remote workers will operate under parameters
that we can't determine, so let them tell us how many jobs they
can handle. As a fallback, we stick to a slightly modified version
of the old algorithm, which also takes into account filedescriptors
used for libraries, memory allocation and other such things.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Add 'wpstats' query to wproc query handler

It doesn't do special-purpose workers yet, but at least it gives
us a base to build on and makes debugging workers quite a lot
easier.

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