afsql: Fix a deadlock when using explicit commits.

When using explicit commits, in case the COMMIT results in an error,
syslog-ng forgot to release a mutex, resulting in a deadlock the next
time the same error happened.

The fix is to do release the mutex in this error path, too.

Signed-off-by: Fried Zoltan <deirf@balabit.hu>
Signed-off-by: Patrick Hemmer <syslogng@stormcloud9.net>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
doc: Fix EXTRA_DIST

There is a \ missing from the end of the second line of EXTRA_DIST,
which results in a couple of files being left out of make dist, which
in turn makes distcheck and building from dist tarballs fail.

This patch adds the missing \.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
log_writer_suspend(): fixed a potential abort when the error-suspend timeout expires

It is caused by the fact that the watches are deinitialized at the time
the timer triggers. Instead of only updating them, restart polling completely
at timer trigger time.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
logwriter: fixed a memory leak for messages that couldn't be flushed at once

Sometimes a message is dequeued, and then can't be posted to the destination
(probably because of an EAGAIN or something like that). In this case
it is readded back to the queue. In this case a reference was lost, causing
a memory leak, but not for all messages, but only for the affected ones.

Reported-By: Evan Rempel <erempel@uvic.ca>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
LogProto: fixed framing error on partial flushes in RFC5424 support

This patch fixes bug that is triggered when syslog-ng receives an EAGAIN
while payload is written to the destination. A patch fixing the issue
was submitted by Gergely Nagy, however I didn't like that solution
refactored the code to something more manageable.

Reported-By: Yuri Arabadji <yuri@fused.com>
Signed-off-by: Fried Zoltan <deirf@balabit.hu>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
afsql: another reset_parallel_push workaround

Lacking a better alternative right now, this patch works around an abort
happening in the SQL destination driver when the target is slow. It's
a single line of code, with 20 lines of comment...

Reported-By: whille <whille@163.com>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
logtransport: handle ENOBUFS on output

FreeBSD returns ENOBUFS on send() failure instead of indicating
this conditions via poll().  The return of ENOBUFS actually is a send
error and is calulated in IP statistics, so the best is to handle it as
a success.  The only alternative would be to return EAGAIN, which could
cause syslog-ng to spin as long as buffer space is unavailable.  Since
I'm not sure how much time that would take and I think spinning the CPU
is not a good idea in general, I just drop the packet in this case.
UDP is lossy anyway

Reported-By: Traiano Welcome <Traiano.Welcome@mtnbusiness.co.za>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
afmongodb: Fix a race condition in the queue & wakeup mechanism

The problem was found and analysed by Whille, the patch is based on
his observations.

The patch corrects a situation where - due to a race condition - the
worker thread could end up in a permanent sleeping state.

Reported-by: whille <whille@163.com>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
driver: fixed possible leak and use-after-free

log_dest_driver_release_queue() was possibly leaking the LogQueue
instances for file destinations when they got reaped. This was
caused by an earlier patch that fixed a crash in reloads,
more specifically this one: c7070e2a6f1c3a312260bcecf49d62028fef27ce

This patch should fix both cases properly, the leak in the file destination
driver and the original crash in the afsocket destination.

Also, this patch fixes a use-after-free condition, the next member of
a GList structure was referenced after it was removed from the list.

Kudos to Jakub for the detailed bug report and Algernon for the origianl
fix.

Reported-By: Jakub Jankowski <shasta@toxcorp.com>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
Revert "[logproto.c] "Invalid Frame Header" in syslog protocol"

This reverts commit 632cf084f2e170466c02f46c7ec1bf9c8a3a85a3.
Merge branch 'upstream/mirror/3.3' into patched/3.3

Conflicts:
	doc/Makefile.am
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>