logthrdestdrv: Centralize the retries() functionality

Instead of implementing retries() for each driver, implement it once, in
LogThrDestDriver. This changes the API of worker->insert: it now
receives the message, and must return one of a number of resulting
states. The parent class will handle it from there. All derived drivers
were updated.

This fixes #201, and due to centralization and common behaviour, also
fixes #202 too.

As a side effect, this adds retries() functionality to amqp(), stomp()
and redis().

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
logthrdestdrv: Introduce threaded_dest_driver_option

This new rule in the grammar will hold all the options that are
centrally implemented by LogThrDestDriver. Currently, this is the
retries() option.

With the function moved to that class, the setter was moved there too,
and all copies were removed from the various drivers.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
cfg-parser: Move "retries" from afsql to cfg-parser

Now that "retries" is implemented by something in core too, move
associated things to cfg-parser.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
logthrdestdrv: Lift a function out of _do_work()

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
logthrdestdrv: Insert as much as we can

In log_threaded_dest_driver_do_insert(), loop while log_queue_pop_head()
returns TRUE (or we need to suspend), so that we don't do a sleep/wakeup
cycle for every single message. We can do this without blocking anyone
else, because this function is running in a dedicated thread.

Thanks to Viktor Juhasz for the suggestion!

Suggested-by: Viktor Juhasz <viktor.juhasz@balabit.com>
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
logthrdestdrv: Refactor the inner insert loop

Instead of locally keeping track of suspension, move that to
LogThrDestDriver->suspended, and set that to TRUE in
_disconnect_and_suspend(), and back to FALSE in _do_work().

This way the control flow is easier to follow, and re-registering can be
moved to _do_work() from _do_insert().

Requested-by: Viktor Juhasz <viktor.juhasz@balabit.com>
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Merge pull request #204 from algernon/f/3.6/central-retries

Centralised retries() for LogThrDestDriver