summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-event
AgeCommit message (Collapse)Author
2015-10-17sd-bus: fix error handling of pthread API callsLennart Poettering
pthread APIs (unlike the rest of libc) return their errors as positive error codes directly from the functions, rather than using errno. Let's make sure we always handle things that way.
2015-09-29sd-event: don't provide priority stabilityDavid Herrmann
Currently, we guarantee that if two event-sources with the same priority fire at the same time, they're always dispatched in the same order. While this might sound nice in theory, there's is little benefit in providing stability on that level. We have no control over the order the events are reported, hence, we cannot guarantee that we get notified about both at the same time. By dropping the stability guarantee, we loose roughly 10% Heap swaps in the prioq on a desktop cold-boot. Krzysztof Kotlenga even reported up to 20% on his tests. This sounds worth optimizing, so drop the stability guarantee.
2015-09-24sd-event: fix prepare priority queue comparison functionKrzysztof Kotlenga
Otherwise a disabled event source can get swapped with an enabled one and cause a severe sd-event malfunction. http://lists.freedesktop.org/archives/systemd-devel/2015-September/034356.html
2015-09-07sd-event: make sure to create a signal queue for the right signalLennart Poettering
We should never access the "signal" part of the event source unless the event source is actually for a signal. In this case it's a child pid handler however, hence make sure to use the right signal. This is a fix for PR #1177, which in turn was a fix for 9da4cb2be260ed123f2676cb85cb350c527b1492.
2015-09-06sd-event: fix call to event_make_signal_dataThomas Hindoe Paaboel Andersen
This looks like a typo from commit 9da4cb2b where it was added.
2015-09-04sd-event: make sure RT signals are not droppedLennart Poettering
RT signals operate in a queue, and we should be careful to never merge two queued signals into one. Hence, makes sure we only ever dequeue a single signal at a time and leave the remaining ones queued in the signalfd. In order to implement correct priorities for the signals introduce one signalfd per priority, so that we only process the highest priority signal at a time.
2015-08-31sd-event: improve debug message when we fail to remove and fd from an epollLennart Poettering
Let's help users to debug issues with epoll fd removal by printing the name of the event source.
2015-08-14tree-wide: generate EBADF when we get invalid fdsLennart Poettering
This is a follow-up to #907, and makes the same change for all our other public APIs.
2015-08-03sd-event: make sure sd_event_now() cannot failLennart Poettering
Previously, if the event loop never ran before sd_event_now() would fail. With this change it will instead fall back to invoking now(). This way, the function cannot fail anymore, except for programming error when invoking it with wrong parameters. This takes into account the fact that many callers did not handle the error condition correctly, and if the callers did, then they kept simply invoking now() as fall back on their own. Hence let's shorten the code using this call, and make things more robust, and let's just fall back to now() internally. Whether now() is used or the cache timestamp may still be detected via the return value of sd_event_now(). If > 0 is returned, then the fall back to now() was used, if == 0 is returned, then the cached value was returned. This patch also simplifies many of the invocations of sd_event_now(): the manual fall back to now() can be removed. Also, in cases where the call is invoked withing void functions we can now protect the invocation via assert_se(), acknowledging the fact that the call cannot fail anymore except for programming errors with the parameters. This change is inspired by #841.
2015-06-17sd-event: make errors on EPOLL_CTL_DEL pseudo-fatalDavid Herrmann
If we call EPOLL_CTL_DEL, we *REALLY* expect the file-descriptor to be present in that given epoll-set. We actually track such state via our s->io.registered flag, so it better be true. Make sure if that's not true, we treat it similar to assert_return() (ie., print a loud warning).
2015-06-15everywhere: port everything to sigprocmask_many() and friendsLennart Poettering
This ports a lot of manual code over to sigprocmask_many() and friends. Also, we now consistly check for sigprocmask() failures with assert_se(), since the call cannot realistically fail unless there's a programming error. Also encloses a few sd_event_add_signal() calls with (void) when we ignore the return values for it knowingly.
2015-06-10logind,sd-event: drop spurious new-linesLennart Poettering
2015-06-04sd-event: don't touch fd's accross forksTom Gundersen
We protect most of the API from use accross forks, but we still allow both sd_event and sd_event_source objects to be unref'ed. This would cause problems as it would unregister sources from the underlying eventfd, hence also affecting the original instance in the parent process. This fixes the issue by not touching the fds on unref when done accross a fork, but still free the memory. This fixes a regression introduced by "udevd: move main-loop to sd-event": 693d371d30fee where the worker processes were disabling the inotify event source in the main daemon.
2015-05-29util: split out signal-util.[ch] from util.[ch]Lennart Poettering
No functional changes.
2015-04-10sd-event: simplify sd_event_run()Lennart Poettering
2015-03-14sd-event: sd_event_run - only return 0 on timeoutTom Gundersen
sd_event_dispatch() returns 0 on FINISH, so let's eat that up.
2015-03-14sd-event: rename PASSIVE/PREPARED to INITIAL/ARMEDTom Gundersen
2015-03-13tree-wide: there is no ENOTSUP on linuxDavid Herrmann
Replace ENOTSUP by EOPNOTSUPP as this is what linux actually uses.
2015-03-13sd-event: fix typoZbigniew Jędrzejewski-Szmek
2015-03-04Remove the cap on epoll eventsHannes Reinecke
Currently the code will silently blank out events if there are more then 512 epoll events, causing them never to be handled at all. This patch removes the cap on the number of events for epoll_wait, thereby avoiding this issue.
2015-02-23remove unused includesThomas Hindoe Paaboel Andersen
This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
2015-02-02sd-event: treat NULL callback for timer events like sig eventsTom Gundersen
In both cases exit the event loop.
2015-01-22tests: use assert_se instead of assertRonny Chevalier
Otherwise they can be optimized away with -DNDEBUG
2014-11-28treewide: no need to negate errno for log_*_errno()Michal Schmidt
It corrrectly handles both positive and negative errno values.
2014-11-28treewide: auto-convert the simple cases to log_*_errno()Michal Schmidt
As a followup to 086891e5c1 "log: add an "error" parameter to all low-level logging calls and intrdouce log_error_errno() as log calls that take error numbers", use sed to convert the simple cases to use the new macros: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/' Multi-line log_*() invocations are not covered. And we also should add log_unit_*_errno().
2014-11-04sd-bus,sd-event: unify error handling of object descriptionsLennart Poettering
a) When getting the description return ENXIO if none is set b) Allow setting a description to NULL c) return ECHILD on fork() like for other calls
2014-11-04sd-event: implicitly set signal event source's descriptions to the signal nameLennart Poettering
2014-11-04sd-event: rename sd_event_source_set_name() to sd_event_source_get_name()Lennart Poettering
To mirror the recent name change of the concept for sd_bus objects, follow the same logic for sd_event_source objects, too.
2014-10-08sd-event: also update signal mask when disconnecting sourcesZbigniew Jędrzejewski-Szmek
2014-10-08sd-event: be more careful when enabling/disabling signalsZbigniew Jędrzejewski-Szmek
When a child event is disabled (in order to be freed) and there is no SIGCHLD signal event, sd_event_source_set_enabled will disable SIGCHLD even if there are other child events. Also remove some unneeded signalfd updates. https://bugs.freedesktop.org/show_bug.cgi?id=84659 Based-on-a-patch-by: Hristo Venev <mustrumr97@gmail.com>
2014-10-03sd-event: check the value of received signalZbigniew Jędrzejewski-Szmek
Appease coverity report #1237775. Also rename ss to n, to make it visually different from ss.
2014-09-15hashmap: introduce hash_ops to make struct Hashmap smallerMichal Schmidt
It is redundant to store 'hash' and 'compare' function pointers in struct Hashmap separately. The functions always comprise a pair. Store a single pointer to struct hash_ops instead. systemd keeps hundreds of hashmaps, so this saves a little bit of memory.
2014-08-28sd-event: simplify sd_event_source_set_name()David Herrmann
free_and_strdup() does exactly the same as sd_event_source_set_name(), use it!
2014-08-28sd-event: use event source name rather than address in debug messagesTom Gundersen
2014-08-28sd-event: allow naming event sourcesTom Gundersen
2014-08-26sd-event: sd_event_prepare - stay in PREPARED if sd_event_wait() indicates ↵Tom Gundersen
that no sources are pending
2014-08-25sd-event: split run into prepare/wait/dispatchTom Gundersen
This will allow sd-event to be integrated into an external event loop, which in turn will allow (say) glib-based applications to use our various libraries, without manually integrating each of them (bus, rtnl, dhcp, ...). The external event-loop should integrate sd-event int he following way: Every iteration must start with a call to sd_event_prepare(), which will return 0 if no event sources are ready to be processed, a positive value if they are and a negative value on error. sd_event_prepare() may only be called following sd_event_dispatch(); a call to sd_event_wait() indicating that no sources are ready to be dispatched; or a failed call to sd_event_dispatch() or sd_event_wait(). A successful call to sd_event_prepare() indicating that no event sources are ready to be dispatched must be followed by a call to sd_event_wait(), which will return 0 if it timed out without event sources being ready to be processed, a negative value on error and a positive value otherwise. sd_event_wait() may only be called following a successful call to sd_event_prepare() indicating that no event sources are ready to be dispatched. If sd_event_wait() indicates that some events sources are ready to be dispatched, it must be followed by a call to sd_event_dispatch(). This is the only time sd_event_dispatch() may be called.
2014-08-20sd-event: add API to access epoll_fdTom Gundersen
This is a prerequisite for integrating sd-event into an external event loop.
2014-08-15sd-event: return 'r' rather than '-errno'Tom Gundersen
2014-08-15sd-event: fix missing needs_rearmTom Gundersen
2014-08-14sd-event: drop _likely_()Tom Gundersen
This is not certain to be likely. Lennart says: a frequent usecase is invoking some function regularly in intervals in such a case every single iteration we'll have to rearm
2014-08-14sd-event: do not arm timers unnecessarilyTom Gundersen
Rather than recalculating the next timeout on every loop, we only do it when something changed.
2014-07-29time-util: add and use USEC/NSEC_INFINIYKay Sievers
2014-07-24sd-event: add support for CLOCK_BOOTTIMETom Gundersen
This requires a very recent kernel (3.15), so care should be taken when using this functionality.
2014-07-11sd-event: don't require a signal event source to be enabled for the child ↵Lennart Poettering
event source to work
2014-07-11sd-event: always call epoll_ctl() on mask-updates if edge-triggeredDavid Herrmann
A call to sd_event_source_set_io_events() skipps calling into the kernel if the new event-mask matches the old one. This is safe for level-triggered sources as the kernel moves them onto the ready-list automatically if events change. However, edge-triggered sources might not be on the ready-list even though events are present. A call to sd_event_source_set_io_events() with EPOLLET set might thus be used to just move the io-source onto the ready-list so the next poll will return it again. This is very useful to avoid starvation in priority-based event queues. Imagine a read() loop on an edge-triggered fd. If we cannot read data fast enough to drain the receive queue, we might decide to skip reading for now and schedule it for later. On edge-triggered io-sources we have to make sure it's put on the ready-list so the next dispatch-round will return it again if it's still the highest priority task. We could make sd-event handle edge-triggered sources directly and allow marking them ready again. However, it's much simpler to let the kernel do that for now via EPOLL_CTL_MOD.
2014-07-10event: pull in sd-event.h from event-util.hLennart Poettering
2014-06-05sd-event: restore correct timeout behaviourLennart Poettering
2014-05-15sd-resolve: add "floating" resolve queriesLennart Poettering
Same story as for sd-bus and sd-event: allow passing NULL to store query in in which case the query is freed automatically.
2014-05-15sd-event: introduce concept of "floating" event sourcesLennart Poettering
These are the counterpart of "floating" bus slots, i.e. event sources that are bound to the lifetime of the event object itself, and thus don't require an explicit reference to be kept.