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 remote-tracking branch '3.3/master'
test_value_pairs: fixed heap corruption & memory leak

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
afinter: fixed a compilation warning

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
cfg-tree: fixed memory leaks in config compilation routines

The objects hash and the name for rules were leaked when processing
the configuration. This patch fixes those.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
cfg-lexer: fixed a memory leak that caused the linked list that holds generator plugins to be leaked

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
cfg-grammar: fixed memory leak when parsing "block" definitions

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
use on-demand LogMessage cloning to implement inmutable messages on parallel log paths

When processing a message, syslog-ng tries hard to avoid copying messages
along the line. The semantics provided by the syslog-ng configuration
is that parallel branches of the log processing pipeline are independent,
e.g. change on one of the branches may not affect the other one.

Earlier, this was implemented by the LogMultiplexer object, before
posting a message to a branch it checked if the branch may change
the message by inspecting the PIF_CLONE flag of the head element. This
didn't handle all cases (e.g. when a rewrite was applied between two
destinations).

This patch delegates this clone-when-needed operation right before the
actual change happens, this also allows some performance improvements
(since the clone may not always be needed).

I introduced the notion of "write-protection" to LogMessage instances,
when an msg is write-protected no changes can be applied. If a LogPipe
needs write access, it needs to acquire that by calling
log_msg_make_writable().

Write-protection is enabled on a LogMessage when it is assumed not to
change. Such an occassion is when it is put on a LogQueue of a destination
which processes messages asynchronously. A similar case is when the
db-parser() puts the message in its correllation state.

Before any writes can be applied, a call to log_msg_make_writable()
needs to be made, which creates a clone if the current LogMessage
is write-protected, or leaves the message be if it isn't.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>