Age | Commit message (Collapse) | Author | Files | Lines |
|
Provided via github. Fixes typos in documentation and comments.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
If we allow users to specify log functions, we should also allow them to
pass a context. This isn't used internally, but may be needed by external
users so provide it.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Major overhaul of the build system. This introduces symbol-versioning for
all exported libraries. Please note that none of these libraries is
stable, yet!
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
EV_ONESHOT will remove idle sources once they have been processed and
EV_SINGLE will only register the source if it hasn't been registered, yet.
For source removal EV_ONESHOT has no effect but EV_SINGLE causes all
events with this cb+data combination to be removed.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
If an entry is marked as 'oneshot' then it will get deleted after it has
been called once. Note that the entry is unlinked _before_ the callback is
called.
If you use 'oneshot'-entries and normal entries with the same cb+data
combination, then you will probably get unexpected behavior. It is not
recommended to do that. In detail, you cannot control which entry is
deleted via a shl_hook_rm() call so you can never be sure whether the
oneshot entry or a normal entry is deleted.
Do not mix oneshot entries with normal entries!
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
If multiple childs die simultaneously, only a single SIGCHLD is queued.
Only after our process got scheduled and we unqueued the SIGCHLD, a next
signal can be queued. Therefore, using SIGCHLD as indicator that a
specific child died does not work reliably.
Instead, we must use waitpid() to wait for childs. Hence, we introduce a
new event-source which does that. It reports the PID/status combination
for each child to the registered callbacks.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
If the signal-registration fails, we need to destroy it again. Otherwise,
it will keep a reference to the current eloop-object and hence it will
never get freed.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
A new EV_ET flag allows ev_fd sources to operate in edge-triggered instead
of level-triggered mode. See epoll(7) for more information.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
We used to disable event sources on EV_HUP to avoid draining the
event-queue for non-edge-triggered sources. However, this turns out to be
not working with special files so we disable it again.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
If the new mask is equal to the old mask, we shouldn't change anything.
This improves performance and avoids syscalls when they aren't needed.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
We used to remove dead FDs from the epoll-loop, but we should do this only
if they are no longer readable. An FD might be dead/HUP but still
readable.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
When enabling the printf() logic for the logging subsystem, several
warnings were produced about missing or wrong specifiers. This fixes all
those occurrences.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
People might want to close file-descriptors before destroying the ev_fd
object if they actually have no direct control of it. For instance if used
through a library.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
We actually allow draining a timer so we cannot be sure that a timer has
valid data that we can read. We already handle the non-blocking case
everywhere, we just missed setting this flag.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
If NULL is passed for timer udpates, we simply assume that the timer
should be disarmed and use a zeroed itimerspec.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
This helper reads the current expiration-count from a timer. This can be
used when waking up from an idle-period or similar to reset the timer.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
This is the last static helper that is moved so as a next step we should
get rid of the "static" library entirely.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
We might argue whether llog should be kept separate, however, shl is a
loose pile of headers and sources so pushing llog into it seems
reasonable.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Instead of including dlist in the static library, we now move it to SHL.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Shl (Static helper library) is the new name of all static helpers in
kmscon that might be shared between different applications.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
pre-cbs are similar to post-cbs but they are called _before_ the actual
dispatching takes place. It can be used to perform any actions before
going to sleep.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
If the dispatch files or is skipped for whatever reason, we should
nevertheless call the post-cbs to avoid any integration errors.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
This is obviously a copy/paste error. This fixes the unregistering to
correctly work now.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
We actually have to register the hook-helper before we can add any hooks.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Instead of using an ev_counter object internally, we now directly create a
new eventfd object. This avoids adding/removing the fd from the epoll-set
constantly when adding/removing idle sources. This should increase
idle-source speed considerably.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
When integrating other event-sources or event-loops into eloop which do
not provide FD-abstractions, we often want to check for specific
conditions before returning from the dispatch-callback or going to sleep.
Therefore, you can now register a post-dispatch-cb and check whether your
alien event source is firing. If it is, simply push an idle-source into
the event-loop and it will fire during the next dispatch without going to
sleep.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
This new helper allows retrieving a single file descriptor which
represents the whole event loop. This is very useful if you want to use
your own event loop in combination with libeloop.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
This removes the nasty dependency to libkmscon-static for libeloop.
Otherwise, we might end up with GLESv2 dependencies here which is really
not what we want.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Finish source code documentation. gtk-doc isn't working very well so this
probably needs to be re-done, but not now...
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
We do not support recursive dispatching so prevent it explicitely.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
We use a temporary array of "to-be-dispatched" event sources while
dispatching. However, we incorrectly set the "count" variable so sources
may access invalid memory when removing themself from the event loop.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
The previous fix incorrectly registered new signals always to the last
found signal which is definitely incorrect. Therefore, we now correctly
traverse the list and register new signals as new signals.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Gcc warns about an uninitialized variable (which technically is correct).
However, there is really no way this can really happen. But to make gcc
happy (and to enhance code readability) we now depend on !sig whether the
list-search was successful.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Small stuff that is not worth putting into a separate library is no moved
into the "static" library which is statically linked into all our
subsystems.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Move every use of log_* to llog_* and make all objects aware of llog
objects.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
When creating a new eloop object, we now require an lloop function so we
can perform conditional logging.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
This comment does not use gtk-doc syntax so remove the extra *.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
We must _never_ take a reference to ourself in a constructor. Otherwise,
the refcnt will be >1 which means if the user calls *_unref() the object
will not get freed.
Therefore, do not add the counter object used for idle sources directly to
the event loop. Instead, add it when the first idle source is registered
and remove it when the last source is removed. This will slightly slow
down performance of idle-sources. However, the whole eloop is not
optimized for speed, yet, so we don't care for now.
Reported-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Add gtk-doc compatible comments to most of the functions in eloop.c.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
We do not maintain event caches so we must make sure that every event
source gets dispatched. If we call epoll_wait() and our buffer gets
filled everytime, then there might be an event source that does not get
dispatched because it is always above the buffer range. Therefore, we now
dynamically increase the cache size when it once gets filled up.
This gets critical if we handle thousands of clients or fds, however, our
use case is limited to some system resources and hence does not suffer
here.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Add comments describing each source and the nesting features.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
epoll has the great feature that the poll object is an fd itself. However,
if we want to use idle-sources, we couldn't add them to the epoll set.
Now, we use a counter source for all idle sources so if we add a single
event-loop as source to another event loop, the idle sources will get
dispatched correctly. Furthermore, we now longer block after handling idle
sources but instead now correctly run idle sources every next round
without sleeping for fd events in between.
Unregister idle sources to avoid hogging the CPU.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
We forgot to actually store the pointer to the new counter object in the
\out variable. Fix this now.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Similar to counter callbacks we now call timer callbacks with 0 as
argument on errors and disable the timer source.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Instead of silently dropping read() errors we now disable the counter and
call the user-supplied callback with 0 as argument so they can react on
errors.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Similar to fd and timer sources we now also support disabling counter
sources via similar functions.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Similar to the fd_enable/disable functions we now also allow the same
operations on timer sources.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Instead of ignoring epoll errors we should forward them to the caller. The
caller can then still decide to ignore errors.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
We sometimes want to be able to enable/disable an fd-source without
allocating memory (for a short period, for instance). Therefore, introduce
two new functions to enable and disable an fd source.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|
|
Instead if implementing complex idle sources we now provide a hook so
other subsystems can register callbacks.
This simplifies the code a lot and doesn't drop any major functionality.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
|