mainloop: destroying dns-cache and scratch buffers per-thread state doesn't need locking

This patch moves the dns_cache_destroy() and scratch_buffers_free() calls
outside of the protection of main_loop_io_workers_idmap_lock. They
accidentaly got there. Shouldn't be a big performance issue, but
can be a bad example for code added later on.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
mainloop: fixed a minor per-thread leak that occurs when a worker thread exits

This patch frees a per-thread condition variable upon exiting from
worker threads. Worker threads are automatically terminated after 10
seconds of idleness, so this might add up if syslog-ng regularly processes
a message every 10 seconds.

Reported-By: Marvin Nipper <Marvin.Nipper@stream.com>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
log_msg_is_value_name_valid(): new function to check if the passed name is useable as a value name

This function used to live in the rewrite-expr-grammar.ym file, copied here
and a generalized a bit. The other function will go away with the next
commit.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
rewrite-expr-grammar: improve error handling for invalid name-value pair names

This change improves the error handling to better pinpoint the issue
we have with the value() parameter of a given rewrite expression.

Both the invalid .SDATA name and trying to change a read-only macro are
handled the same, with a nice error message.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
throttle: don't let the bucket counter go less than zero

When the LogWriter ignores the throttle setting (for instance when flushing
the destination at reload/exit time), the throttle_buckets can go
below zero, which is unexpected. Don't let that happen.

Signed-off-by: Juhasz Viktor <jviktor@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
preparations for 3.3.5
afmongodb: Fix a deadlock at deinit time.

There is a race condition between the writer thread and stop_threads
(via deinit): if deinit sends the signal just at the wrong time, then
the worker thread willl never wake up, as the main thread is already
waiting for a join to finish.

The fix is to lock the queue_mutex before signalling, that eliminates
the race. This patch does just that.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
afsocket: handle DNS failures as if it was a connection failure

Instead of preventing the startup completely.

Reported-By: Heiko Gerstung <heiko@am-anger-1.de>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
afinter: Make the parent class LogSrcDriver, instead of LogDriver.

The parent of AFInterSourceDriver should be LogSrcDriver, because
that's the struct we pass down to it anyway, and other parts of the
code will cast it back to LogSrcDriver, too.

But if its parent is LogDriver, as it was, we were corrupting the
later parts of the original LogSrcDriver, with values from
AFInterSourceDriver.

Many thanks to Peter Eisenlohr <peter.eisenlohr@inform-software.com>
for initial debugging, and for pinpointing mark messages as the
triggers.

Reported-by: Peter Czanik <czanik@balabit.hu>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Merge branch 'upstream/mirror/3.3' into patched/3.3
Merge branch 'patched/3.3' into debian/3.3
debian/changelog: Update to 3.3.5.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>