LogPipe: remove "sender" argument from log_pipe_notify()

This argument was unused anyway and restricted notify invocations from LogPipe
instances.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
LogReader: removed LogReaderWatch typedef and unused member

This was dead code is the remnants of the change to a multithreaded
architecture, not used anymore.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
logreader: remove unneeded log_proto_server_prepare() call from log_reader_init_watches

The results of this call were not needed at all.

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

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
logreader: don't rely on the fact that iv_fd was registered to decide polling strategy

I'm trying to set the logic straight that tries to detect how we are polling
the source. Instead of checking iv_fd_registered() on iv_fd, use
pollable_state for that.

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

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
logreader: factor out log_reader_update_follow_timer()

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
logreader: added idempotency to _start_watches() and stop_watches()

Logreader now tracks if its I/O watches are running using a boolean
variable.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
LogReader: introduce the LogReaderPollEvents interface

This is an intermediate step that introduces a LogReader specific private
class to perform I/O polling.  In the subsequent patches this will become
more general so it can be applied by LogWriter instances as well.  This
patch changes the LogReader logic to instantiate the appropriate class at a
single location and rely on LogReaderPollEvents descendants to perform the
work it needs but with a uniform interface.

This patch introduces the abstract base class (LogReaderPollEvents) and two
descendants factored out of LogReader, LogReaderPollFileChanges and
LogReaderPollFd.  The first performing the follow-freq() style time based
polling, the second merely polling the specified fd using poll(2).

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
PollEvents: implement PollEvents abstract class

The new PollEvents class is factored out from LogReader as a generic
interface to implement event polling both in LogReader and LogWriter.

The plan is to have a generic PollFdEvents class to poll for fd I/O events,
and a separate class for file-change polling when using follow-freq().

Other polling methods may become available in the future.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
PollFileChanges: new class, factored out from LogReader

This class factors out PollFileChanges from the logreader module, making it
less tightly coupled with LogReader and indicating this also in the name.
This is right now affile specific as only regular files are polled using a
timer.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
PollFdEvents: factor out from LogReader

This patch factors out LogReaderPollFd as a LogReader independent class into
its separate module as a derived class of PollEvents.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
LogReader: drop log_reader_start_watches()

Instead of having a separate start_watches() method, make update_watches()
aware if watches are running and react accordingly. Previously both
functions were invoked anyway.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
LogReader: drop constructor arguments in favour of log_reader_reopen

Instead of passing the LogProtoServer and PollEvents instance in the
constructor, pass those using log_reader_reopen() once the constructor
has finished. This makes LogWriter and LogReader a bit more similar and
provides a single path for passing this data.

This patch also cleans up the previously unused log_reader_reopen()
interface and removes most of the arguments, which should've been
passed to more specialized methods.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
affile: make follow freq completely file source specific

Instead of stuffing the follow-freq parameter to LogReaderOptions, move it
to AFFileSourceDriver where it is actually relevant. This patch also
removes GlobalConfig->follow_freq, which was never set anywhere in the
code.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
LogProtoServer: remove unused fd argument from prepare

With the recent LogReader/PollEvents split, it is now possible to remove
the fd return argument from LogProtoServer->prepare. This patch
does exactly that.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
LogReader: simplify log_reader_update_watches() call

This patch tries to make the code for log_reader_update_watches() a bit more readable
by breaking out code into smaller, well named functions.

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