manual pages: replace generated manual pages with the XML source

This patch changes the included manual pages to be covered under the
GPL and also a means to regenerate them from their source format (XML).

Signed-off-by: Robert Fekete <frobert@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
debian: Fix SOURCE_REVISION for cases where the package is not a snapshot.

In case the package was not a snapshot, the distribution version never
made it into SOURCE_REVISION. This is now fixed by adding that as a
separate step, independent of the version mungling.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
debian: Sync with GCS.

Sync the packaging with GCS: upgrade to debhelper 9, and multi-arch.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
debian/control: Only add Pre-Depends to those packages that need it.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
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>
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>
Merge branch 'patched/3.3' into debian/3.3
debian: changelog update

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
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
Merge branch 'patched/3.3' into debian/3.3