logwriter: Implementing the late acknowledge mechanism on the writer's side

Signed-off-by: Daniel Gados <gdani@balabit.hu>
logqueue: refactoring pop_head and adding log_queue_rewind_backlog to log_writer_flush

Signed-off-by: Daniel Gados <gdani@balabit.hu>
logproto-client: Implemenation of the 'keep one message' functionality

Signed-off-by: Daniel Gados <gdani@balabit.hu>
logmsg: adding the abort flag to the ack_and_ref member of LogMsg

It may happen that a message is sent to multiple destinations and
some of these destination have ack-ed the message but the queue of
the other writers have been freed. In this case these writers ack
the messages with AckType AT_ABORT which means that the message is
not processed and never will be.
To be correct we have to transfer the AT_ABORT all way along the
ack-path to notify the source that the message is not processed
on some paths and never will be to decrement the references to
the message. When the message is processed on all paths then the ack
is not only to decrement the references to the message but to change
the actual window size and save the actual buffer position to the
persist file.
The order of processed acks (AT_PROCESS) and unprocessed acks (AT_ABORT)
is undetermined. We have to accumulate the aborts and if at least one
writer acks with AT_ABORT (even if it is not the last one), we have to
transfer the AT_ABORT state to the source from log_msg_ack and
log_msg_refcache_stop.
To achive the above mentioned functionality the TLS_BLOCK has been
extended with a logmsg_cached_abort flag holding 0 or 1 and the member
ack_and_ref is change the following way: the lowest 15 bits hold the ref
counter (instead of 16 bits), then the next 15 bits hold the ack counter
(instead of 16 bits) and then 1 bit is holding the abort-flag (the last
one bit is unused at the moment).

Signed-off-by: Daniel Gados <gdani@balabit.hu>