summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-event/sd-event.c
AgeCommit message (Collapse)Author
2016-06-30sd-event: expose the event loop iteration counter via ↵Lennart Poettering
sd_event_get_iteration() (#3631) This extends the existing event loop iteration counter to 64bit, and exposes it via a new function sd_event_get_iteration(). This is helpful for cases like issue #3612. After all, since we maintain the counter anyway, we might as well expose it. (This also fixes an unrelated issue in the man page for sd_event_wait() where micro and milliseconds got mixed up)
2016-06-06sd-event: port over to new triple timestamp logicLennart Poettering
2016-04-22tree-wide: don't assume CLOCK_BOOTIME is generally availableLennart Poettering
Before we invoke now(CLOCK_BOOTTIME), let's make sure we actually have that clock, since now() will otherwise hit an assert. Specifically, let's refuse CLOCK_BOOTTIME early in sd-event if the kernel doesn't actually support it. This is a follow-up for #3037, and specifically: https://github.com/systemd/systemd/pull/3037#issuecomment-210199167
2016-04-17tree-wide: fall back to now(CLOCK_MONOTONIC) if CLOCK_BOOTTIME unsupported ↵Lubomir Rintel
(#3037) It was added in 2.6.39, and causes an assertion to fail when running in mock hosted on 2.6.32-based RHEL-6: Assertion 'clock_gettime(map_clock_id(clock_id), &ts) == 0' failed at systemd/src/basic/time-util.c:70, function now(). Aborting.
2016-04-12tree-wide: add new SIGNAL_VALID() macro-like function that validates signal ↵Lennart Poettering
numbers And port all code over to use it.
2016-02-22tree-wide: make ++/-- usage consistent WRT spacingVito Caputo
Throughout the tree there's spurious use of spaces separating ++ and -- operators from their respective operands. Make ++ and -- operator consistent with the majority of existing uses; discard the spaces.
2016-02-12time-util: map ALARM clockids to non-ALARM clockids in now()Lennart Poettering
Fixes: #2597
2016-02-10tree-wide: remove Emacs lines from all filesDaniel Mack
This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
2016-02-01sd-event: permit a USEC_INFINITY timeout as an alternative to a disabling an ↵Lennart Poettering
event source This should simplify handling of time events in clients and is in-line with the USEC_INFINITY macro we already have. This way setting a timeout to 0 indicates "elapse immediately", and a timeout of USEC_INFINITY "elapse never".
2016-02-01sd-event: when determining the last allowed time a time event may elapse, ↵Lennart Poettering
deal with overflows
2016-01-18sd-event: fix theoretical leak on error in event_make_signal_dataZbigniew Jędrzejewski-Szmek
2016-01-18sd-event: check clock argument to sd_event_now()Zbigniew Jędrzejewski-Szmek
sd_event_now() is a public function, so we must check all arguments for validity. Update man page and add tests. Sample debug message: Assertion 'IN_SET(clock, CLOCK_REALTIME, CLOCK_REALTIME_ALARM, CLOCK_MONOTONIC, CLOCK_BOOTTIME, CLOCK_BOOTTIME_ALARM)' failed at src/libsystemd/sd-event/sd-event.c:2719, function sd_event_now(). Ignoring.
2016-01-12sd-event: minor fixups to delays profiling changesVito Caputo
2016-01-12sd-event: instrument sd_event_run() for profiling delaysVito Caputo
Set SD_EVENT_PROFILE_DELAYS to activate accounting and periodic logging of the distribution of delays between sd_event_run() calls. Time spent in dispatching as well as time spent outside of sd_event_run() is measured and accounted for. Every 5 seconds a logarithmic histogram loop iteration delays since 5 seconds previous is logged. This is useful in identifying the frequency and magnitude of latencies affecting the event loop, which should be kept to a minimum.
2015-12-21sd-event: improve debugging of event source errorsDaniel Mack
Printing the pointer variable really doesn't help, so drop that. Instead, add a string lookup table for the EventSourceType enum, and print the type of event source in case of errors.
2015-11-22sd-event: use prioq_ensure_allocated where possibleEvgeny Vereshchagin
2015-11-19sd-event: define a new PREPARING stateLennart Poettering
We already have a state RUNNING and EXITING when we dispatch regular and exit callbacks. Let's introduce a new state called PREPARING that is active while we invoke preparation callbacks. This way we have a state each for all three kinds of event handlers. The states are currently not documented, hence let's add a new state to the end, before we start documenting this.
2015-11-19sd-event: make _ref() calls NOPs when NULL is passed to themLennart Poettering
Let's make _ref() calls happy when NULL is passed to them, and simply return NULL without any assertion logic. This makes them nicely symmetric to the _unref() calls which also are happy to take NULL and become NOPs then.
2015-11-17tree-wide: use right cast macros for UIDs, GIDs and PIDsLennart Poettering
2015-10-27util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering
2015-10-25util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering
There are more than enough to deserve their own .c file, hence move them over.
2015-10-24util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering
string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
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-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.
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>